﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Oracle.DataAccess.Client;
using Entity;
using System.Text;
using Access.BLL;
using System.Data;
using System.Configuration;
using Newtonsoft.Json;
using System.Text.RegularExpressions;
using System.IO;
using System.Reflection;
using System.Threading;
using System.Net; 
using YiWangTongBan.Entity; 
using System.Linq.Expressions;
using System.Net.Http;


namespace YiWangTongBan.BLL
{
    public class DLLYWTB_WS
    {
        string s_suffix_notEmpty = string.Format(" {0}", "不能为空");
        BusinessLogsticBase _BusinessLogsticBase = new BusinessLogsticBase();
        AccessDataBase _AccessDataBase = new AccessDataBase();
        /// <summary>
        /// 报修
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <returns></returns>
        public XiangYingEntity Repaire(RepairEntity rpEntity, string S_IP)
        {
            string URL_BAOXIU_HOT = ConfigurationManager.AppSettings["URL_BAOXIU_HOT"];
            string METHODNAME_BAOXIU_HOT = ConfigurationManager.AppSettings["METHODNAME_BAOXIU_HOT"];
            string STR_CURRENT_COMPANY = ConfigurationManager.AppSettings["CURRENT_COMPANY"];
            string body = JsonConvert.SerializeObject(rpEntity);
            #region 定义变量
            int i_WsNo = (int)Web_Service_Name.Repair;//接口名称在枚举中对应的编号
            int i_code = 0;
            bool b_isGood = true;
            string s_result = string.Empty;//记录操作结果
            string message = "";//水务之声接口返回json串
            StringBuilder s_message = new StringBuilder();//记录参数和操作结果&方法参数
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_BAOXIUXX _outWTB_BAOXIUXX = new WTB_BAOXIUXX();
            XiangYingEntity _XiangYingEntity = new XiangYingEntity();
            #endregion

            try
            {

                #region 记录参数
                LogUtil.Info("Repaire方法接收" + S_IP + "请求：" + body);
                
                #endregion

                #region 验证参数
                //不能为空
                if (string.IsNullOrEmpty(rpEntity.incident_id)) { i_code = 11; s_result = "申请单唯一ID" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.apply_no)) { i_code = 11; s_result = "统一审批编码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.shw_address)) { i_code = 11; s_result = "用水地址" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.applicant)) { i_code = 11; s_result = "申请人" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.appdate)) { i_code = 11; s_result = "申请时间" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.incident_type)) { i_code = 11; s_result = "申请单类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.cert_type)) { i_code = 11; s_result = "证件类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.cert_number)) { i_code = 11; s_result = "证件号码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.bx_dttm)) { i_code = 11; s_result = "报修时间" + s_suffix_notEmpty; goto last; }
                #endregion

                if (STR_CURRENT_COMPANY == "PDWLY")//判断当前公司是否为威立雅
                {
                    LogUtil.Info("Repaire方法开始转发请求：" + body);
                    message = _BusinessLogsticBase.QueryPostWebService(URL_BAOXIU_HOT, METHODNAME_BAOXIU_HOT, body);//调水务之声接口
                    LogUtil.Info("Repaire方法接收" + URL_BAOXIU_HOT + "响应：" + message);
                }

                #region 验证该INCIDENT_ID记录是否已存在
                ////b_isGood = _BusinessLogsticBase.IsIncident_IDExist(rpEntity.incident_id);
                ////if (!b_isGood)
                ////{
                ////    i_code = 500;
                ////    s_result = string.Format("申请单号:{0}已存在", rpEntity.incident_id);
                ////    s_message.AppendFormat("申请单号:{0}已存在", rpEntity.incident_id);
                ////    return _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                ////}
                #endregion

                _BusinessLogsticBase.CreateRepairEntity(rpEntity, out _outWTB_YEWUZB, out _outWTB_BAOXIUXX);
                #region 写入数据库
                //写入数据库主表
                b_isGood = _BusinessLogsticBase.IsMainInsGoodByID(_outWTB_YEWUZB);
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    ////return _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入子表
                b_isGood = _BusinessLogsticBase.IsChildInsGoodByResult(_outWTB_BAOXIUXX,_BusinessLogsticBase.getBusinessType(rpEntity.incident_type));////需修改成string 类型
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_BAOXIUXX表新增失败", rpEntity.incident_id);
                    ////return _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入证件列表
                if (b_isGood)
                {
                    if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                    {
                        b_isGood = _BusinessLogsticBase.IsInsertCertListGood(rpEntity.CertList, _outWTB_YEWUZB);
                        if (!b_isGood)
                        {
                            i_code = 12;
                            s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 证件列表数和成功写入WTB_WENJIANXX表记录数不符", rpEntity.incident_id);
                            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            goto last;
                        }
                        else
                        {
                            i_code = 200;
                            s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                        }
                    }
                    else
                    {
                        i_code = 200;
                        s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                        s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                    }
                }
                //else
                //{
                //    i_code = 200;
                //    s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                //    s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                //}
                #endregion
            }
            catch (Exception ex)
            {
                i_code = 12;
                s_result = string.Format("申请单号：{0}操作出现异常", rpEntity.incident_id);
                s_message.AppendFormat("申请单号：{0}操作失败,错误：{1}", rpEntity.incident_id, ex.Message);
                ////return _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                goto last;
            }
            finally
            {

                //记日志
                LogUtil.Info(s_message.ToString());

            }
        last:
            if (STR_CURRENT_COMPANY == "PDWLY")//判断当前公司是否为威立雅
            {
                XiangYingEntity result = JsonConvert.DeserializeObject<XiangYingEntity>(message);
                LogUtil.Info("Repaire方法转发响应：" + message);
                return result;//_BusinessLogsticBase.GetXiangYingResult(i_code,s_result);
            }
            else
            {
                XiangYingEntity result = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                LogUtil.Info("Repaire方法响应：" + message);
                return result;
            }
        }

        #region 单位接水
        //public XiangYingEntity CompanyApply(CompanyApplyEntity rpEntity, string S_IP)
        //{
        //    #region 定义变量
        //    int i_WsNo = (int)Web_Service_Name.CompanyApply;//接口名称在枚举中对应的编号
        //    int i_code = 0;
        //    bool b_isGood = true;
        //    string s_incident_type = "02";//此处为incident_type
        //    string s_result = string.Empty;//记录操作结果
        //    string body = "";
        //    string str_out = "";
        //    StringBuilder s_message = new StringBuilder();
        //    WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
        //    WTB_JIESHUIXX _outWTB_JIESHUIXX = new WTB_JIESHUIXX();
        //    XiangYingEntity _XiangYingEntity = new XiangYingEntity();
        //    #endregion

        //    try
        //    {
        //        #region 记录参数
        //        body = JsonConvert.SerializeObject(rpEntity);
        //        LogUtil.Info("CompanyApply方法接收" + S_IP + "请求：" + body);
        //        //s_message.Append(_BusinessLogsticBase.GetParameterByMethod(i_WsNo, rpEntity));
        //        #endregion

        //        #region 验证参数
        //        //不能为空
        //        if (string.IsNullOrEmpty(rpEntity.incident_id)) { i_code = 500; s_result = "申请单唯一ID" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.apply_no)) { i_code = 500; s_result = "统一审批编码" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.shw_address)) { i_code = 500; s_result = "用水地址" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.applicant)) { i_code = 500; s_result = "申请人" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.appdate)) { i_code = 500; s_result = "申请时间" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.cert_type)) { i_code = 500; s_result = "证件类型" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.cert_number)) { i_code = 500; s_result = "证件号码" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.company_name)) { i_code = 500; s_result = "企业名称" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.company_type)) { i_code = 500; s_result = "企业类型" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.social_credit_code)) { i_code = 500; s_result = "统一社会信用代码" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.business_type)) { i_code = 500; s_result = "业务类型" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.address)) { i_code = 500; s_result = "接水地址" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.apply_content)) { i_code = 500; s_result = "申请内容" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.project)) { i_code = 500; s_result = "项目名称" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.contact_person)) { i_code = 500; s_result = "经办人" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.phone)) { i_code = 500; s_result = "联系电话" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.mail)) { i_code = 500; s_result = "邮箱" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.ysxqsc)) { i_code = 500; s_result = "用水需求（生活/生产）" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.ysxqxf)) { i_code = 500; s_result = "用水需求（消防）" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.overall_floorage)) { i_code = 500; s_result = "总建筑面积" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.qyzjlx)) { i_code = 500; s_result = "企业证件" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.qyzjbm)) { i_code = 500; s_result = "企业证件编码" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.frxm)) { i_code = 500; s_result = "法人姓名" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.frsfzhm)) { i_code = 500; s_result = "法人身份证号" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.ydxz)) { i_code = 500; s_result = "用地性质" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.build_type)) { i_code = 500; s_result = "建筑物类型" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.wygz)) { i_code = 500; s_result = "单位名称（盖章）" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.khxz)) { i_code = 500; s_result = "客户性质" + s_suffix_notEmpty; goto last; }
        //        if (string.IsNullOrEmpty(rpEntity.sqlb)) { i_code = 500; s_result = "申请类别" + s_suffix_notEmpty; goto last; }
        //        //验证decimal
        //        if (!_BusinessLogsticBase.IsDecimal(rpEntity.ysxqsc)) { i_code = 500; s_result = "用水需求（生活/生产）" + s_suffix_decmal; goto last; }
        //        if (!_BusinessLogsticBase.IsDecimal(rpEntity.ysxqxf)) { i_code = 500; s_result = "用水需求（消防）" + s_suffix_decmal; goto last; }
        //        //验证证件列表
        //        //if (!_BusinessLogsticBase.ValidateCertList(rpEntity.CertList, out str_out))
        //        //{
        //        //    i_code = 500;
        //        //    s_result = str_out;
        //        //    goto last;
        //        //}
        //        #endregion

        //        #region 验证该INCIDENT_ID记录是否已存在
        //        b_isGood = _BusinessLogsticBase.IsIncident_IDExist(rpEntity.incident_id);
        //        if (!b_isGood)
        //        {
        //            i_code = 500;
        //            s_result = string.Format("申请单号:{0}已存在", rpEntity.incident_id);
        //            s_message.AppendFormat("申请单号:{0}已存在", rpEntity.incident_id);
        //            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
        //            goto last;
        //        }
        //        #endregion

        //        _BusinessLogsticBase.CreateCompanyApplyEntity(rpEntity, out _outWTB_YEWUZB, out _outWTB_JIESHUIXX);
        //        #region 写入数据库
        //        //写入数据库主表
        //        b_isGood = _BusinessLogsticBase.IsMainInsGoodByID(_outWTB_YEWUZB);
        //        if (!b_isGood)
        //        {
        //            i_code = 500;
        //            s_result = string.Format("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
        //            s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
        //            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
        //        }
        //        //写入子表
        //        b_isGood = _BusinessLogsticBase.IsChildInsGoodByResult(_outWTB_JIESHUIXX, s_incident_type);////需修改成string 类型
        //        if (!b_isGood)
        //        {
        //            i_code = 500;
        //            s_result = string.Format("申请单号:{0} WTB_JIESHUIXX表新增失败", rpEntity.incident_id);
        //            s_message.AppendFormat("申请单号:{0} WTB_JIESHUIXX表新增失败", rpEntity.incident_id);
        //            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
        //            goto last;
        //        }
        //        //写入证件列表
        //        if (b_isGood && _BusinessLogsticBase.IsInsertCertListGood(rpEntity.CertList, _outWTB_YEWUZB))
        //        {
        //            i_code = 200;
        //            s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
        //            s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
        //        }
        //        else
        //        {
        //            i_code = 500;
        //            s_result = string.Format("申请单号:{0} 证件列表数和成功写入WTB_WENJIANXX表记录数不符", rpEntity.incident_id);
        //            s_message.AppendFormat("申请单号:{0} 证件列表数和成功写入WTB_WENJIANXX表记录数不符", rpEntity.incident_id);
        //            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
        //            goto last;
        //        }
        //        #endregion
        //    }
        //    catch (Exception ex)
        //    {
        //        i_code = 500;
        //        s_result = string.Format("申请单号：{0}操作失败,错误：{1}", rpEntity.incident_id, ex.Message);
        //        s_message.AppendFormat("申请单号：{0}操作失败,错误：{1}", rpEntity.incident_id, ex.Message);
        //        _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
        //        goto last;
        //    }
        //    finally
        //    {
        //        //记日志
        //        LogUtil.Info(s_message.ToString());
        //    }
        //last:
        //    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
        //    _XiangYingEntity.INCIDENT_ID = rpEntity.incident_id;
        //    body = JsonConvert.SerializeObject(_XiangYingEntity);
        //    LogUtil.Info("CompanyApply方法返回" + S_IP + "结果：" + body);
        //    return _XiangYingEntity;// _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
        //}
        #endregion

        /// <summary>
        /// 居民住宅单独接水
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <returns></returns>
        public XiangYingEntity ResidentApply(ResidentApplyEntity rpEntity, string S_IP)
        {
            #region 定义变量
            int i_WsNo = (int)Web_Service_Name.ResidentApply;//接口名称在枚举中对应的编号
            int i_code = 0;
            bool b_isGood = true;
            string s_result = string.Empty;//记录操作结果
            string body = "";
            StringBuilder s_message = new StringBuilder();
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_JIESHUIXX _outWTB_JIESHUIXX = new WTB_JIESHUIXX();
            XiangYingEntity _XiangYingEntity = new XiangYingEntity();
            #endregion

            try
            {
                #region 记录参数
                //s_message.Append(_BusinessLogsticBase.GetParameterByMethod(i_WsNo, rpEntity));
                body = JsonConvert.SerializeObject(rpEntity);
                LogUtil.Info("ResidentApply方法接收" + S_IP + "请求：" + body);
                #endregion

                #region 验证参数
                //不能为空
                if (string.IsNullOrEmpty(rpEntity.incident_id)) { i_code = 11; s_result = "申请单唯一ID" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.apply_no)) { i_code = 11; s_result = "统一审批编码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.shw_address)) { i_code = 11; s_result = "用水地址" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.applicant)) { i_code = 11; s_result = "申请人" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.appdate)) { i_code = 11; s_result = "申请时间" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.incident_type)) { i_code = 11; s_result = "申请单类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.cert_type)) { i_code = 11; s_result = "证件类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.cert_number)) { i_code =11; s_result = "证件号码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.business_type)) { i_code = 11; s_result = "业务类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.xzq)) { i_code = 11; s_result = "行政区" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.jdz)) { i_code = 11; s_result = "街道镇" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.is_transfer_order)) { i_code = 11; s_result = "是否转单" + s_suffix_notEmpty; goto last; }
                //申请转单水务公司
                if (!string.IsNullOrEmpty(rpEntity.is_transfer_order) && rpEntity.is_transfer_order == "1" && string.IsNullOrEmpty(rpEntity.shw_company_source))
                { i_code = 11; s_result = "申请转单的水务公司" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.fczhm)) { i_code = 11; s_result = "房产证号码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.address)) { i_code = 11; s_result = "接水地址" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.apply_content)) { i_code = 11; s_result = "申请内容" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.apply_memo)) { i_code = 11; s_result = "申请说明" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.con_name)) { i_code = 11; s_result = "联系人" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.phone)) { i_code = 11; s_result = "联系手机" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.contact_address)) { i_code = 11; s_result = "联系地址" + s_suffix_notEmpty; goto last; }
                //验证列表
                if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                {
                    b_isGood = new BusinessLogsticBase().ValidateCertList(rpEntity.CertList, out s_result);
                    if (!b_isGood) { i_code = 11; goto last; }
                }

                #endregion

                #region 验证该INCIDENT_ID记录是否已存在
                b_isGood = _BusinessLogsticBase.IsIncident_IDExist(rpEntity.incident_id);
                if (!b_isGood)
                {
                    i_code = 9;
                    s_result = string.Format("申请单号:{0}已存在", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0}已存在", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                #endregion

                
                _BusinessLogsticBase.CreateResidentEntity(rpEntity, out _outWTB_YEWUZB, out _outWTB_JIESHUIXX);

                //ResultEntity _result=searchWaterUserInfo(_outWTB_YEWUZB.CARD_ID, _outWTB_YEWUZB.BUSINESS_TYPE, "");//再次调用业务校验接口
                //b_isGood = _result.isSuccess;
                //if (!b_isGood)
                //{
                //    i_code = 500;
                //    s_result = string.Format("申请单号:{0} 操作出现异常 {1}", rpEntity.incident_id, _result.message);
                //    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                //    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                //    goto last;
                //}
                #region 写入数据库
                //写入数据库主表
                b_isGood = _BusinessLogsticBase.IsMainInsGoodByID(_outWTB_YEWUZB);
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入子表
                b_isGood = _BusinessLogsticBase.IsChildInsGoodByResult(_outWTB_JIESHUIXX, "01");////需修改成string 类型
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_JIESHUIXX表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入证件列表
                if (b_isGood)
                {
                    if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                    {
                        b_isGood = _BusinessLogsticBase.IsInsertCertListGood(rpEntity.CertList, _outWTB_YEWUZB);
                        if (!b_isGood)
                        {
                            i_code = 12;
                            s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 证件列表数和成功写入WTB_WENJIANXX表记录数不符", rpEntity.incident_id);
                            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            goto last;
                        }
                        else
                        {
                            i_code = 200;
                            s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                        }
                    }
                    else
                    {
                        i_code = 200;
                        s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                        s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                i_code = 12;
                s_result = string.Format("申请单号：{0} 操作出现异常", rpEntity.incident_id);
                s_message.AppendFormat("申请单号：{0}操作失败,错误：{1}", rpEntity.incident_id, ex.Message);
                _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                goto last;
            }
            finally
            {
                //记日志
                LogUtil.Info(s_message.ToString());
            }
        last:
            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
            _XiangYingEntity.incident_id = rpEntity.incident_id;
            body = JsonConvert.SerializeObject(_XiangYingEntity);
            LogUtil.Info("ResidentApply方法返回" + S_IP + "结果：" + body);
            return _XiangYingEntity;
        }

        /// <summary>
        /// 居民过户/单位过户
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <returns></returns>
        public XiangYingEntity Transfer(TransferEntity rpEntity, string S_IP)
        {
            #region 定义变量
            string STR_CURRENT_COMPANY = ConfigurationManager.AppSettings["CURRENT_COMPANY"];
            int i_code = 0;
            bool b_isGood = true;
            string s_incident_type = "15";//此处为incident_type
            string s_result = string.Empty;//记录操作结果
            string body = "";
            StringBuilder s_message = new StringBuilder();
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_GUOHUXX _outWTB_GUOHUXX = new WTB_GUOHUXX();
            XiangYingEntity _XiangYingEntity = new XiangYingEntity();
            #endregion

            try
            {
                #region 记录参数
                //s_message.Append(_BusinessLogsticBase.GetParameterByMethod(i_WsNo, rpEntity));
                body = JsonConvert.SerializeObject(rpEntity);
                LogUtil.Info("Transfer方法接收" + S_IP + "请求：" + body);
                #endregion

                #region 验证参数
                //不能为空
                if (string.IsNullOrEmpty(rpEntity.incident_id)) { i_code = 11; s_result = "申请单唯一ID" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.apply_no)) { i_code = 11; s_result = "统一审批编码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.custom_type)) { i_code = 11; s_result = "客户类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.applicant)) { i_code = 11; s_result = "申请人" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.appdate)) { i_code = 11; s_result = "申请时间" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.is_transfer_order)) { i_code = 11; s_result = "是否转单" + s_suffix_notEmpty; goto last; }
                //申请转单水务公司
                //if (!string.IsNullOrEmpty(rpEntity.is_transfer_order) && rpEntity.is_transfer_order == "1" && string.IsNullOrEmpty(rpEntity.shw_company_source))
                //{ i_code = 11; s_result = "申请转单的水务公司" + s_suffix_notEmpty; goto last; } 允许为空
                //if (string.IsNullOrEmpty(rpEntity.cert_type)) { i_code = 11; s_result = "证件类型" + s_suffix_notEmpty; goto last; }
                //if (string.IsNullOrEmpty(rpEntity.cert_number)) { i_code = 11; s_result = "证件号码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.business_type)) { i_code = 11; s_result = "业务类型" + s_suffix_notEmpty; goto last; }
                if (rpEntity.business_type != "14" && rpEntity.business_type != "15") { i_code = 11; s_result = "业务类型传值不正确！"; goto last; }

                if (rpEntity.business_type!="14" && string.IsNullOrEmpty(rpEntity.company_name)) { i_code = 500; s_result = "单位过户，企业名称" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.card_id)) { i_code = 11; s_result = "销根号" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.new_entity_name)) { i_code = 11; s_result = "新业主客户名称" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.id_type)) { i_code = 11; s_result = "新业主证件类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.id_nbr)) { i_code = 11; s_result = "新业主证件号码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.fczjlx)) { i_code = 11; s_result = "房产证件类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.fczjhm)) { i_code = 11; s_result = "房产证件号码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.address)) { i_code = 11; s_result = "用水地址" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.bill_address)) { i_code = 11; s_result = "账单送达地址" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.transfer_reason)) { i_code = 11; s_result = "变更原因" + s_suffix_notEmpty; goto last; }
                //if (string.IsNullOrEmpty(rpEntity.use_type)) { i_code = 11; s_result = "客户类型" + s_suffix_notEmpty; goto last; }

                if (rpEntity.business_type != "14" && string.IsNullOrEmpty(rpEntity.contacts)) { i_code = 11; s_result = "联系人" + s_suffix_notEmpty; goto last; }
                if (rpEntity.business_type != "14" && string.IsNullOrEmpty(rpEntity.contact_num)) { i_code = 11; s_result = "联系人电话" + s_suffix_notEmpty; goto last; }

                if (string.IsNullOrEmpty(rpEntity.comm_rte_type_cd)) { i_code = 11; s_result = "人员联系类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.contact_value)) { i_code = 11; s_result = "电话号码" + s_suffix_notEmpty; goto last; }
                //if (string.IsNullOrEmpty(rpEntity.gyshtbh)) { i_code = 11; s_result = "合同编号" + s_suffix_notEmpty; goto last; } 业务系统生成
                if (rpEntity.business_type != "14" && string.IsNullOrEmpty(rpEntity.typc)) { i_code = 11; s_result = "同一批次" + s_suffix_notEmpty; goto last; }
                //验证列表
                if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                {
                    b_isGood = new BusinessLogsticBase().ValidateCertList(rpEntity.CertList, out s_result);
                    if (!b_isGood) { i_code = 11; goto last; }
                }

                #endregion

                #region 验证该INCIDENT_ID记录是否已存在
                b_isGood = _BusinessLogsticBase.IsIncident_IDExist(rpEntity.incident_id);
                if (!b_isGood)
                {
                    i_code = 9;
                    s_result = string.Format("申请单号:{0}已存在", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0}已存在", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                #endregion
                _BusinessLogsticBase.CreateTransferEntity(rpEntity, out _outWTB_YEWUZB, out _outWTB_GUOHUXX);

                ResultEntity _result = searchWaterUserInfo(_outWTB_YEWUZB.CARD_ID, _outWTB_YEWUZB.BUSINESS_TYPE, "","0");//再次调用业务校验接口
                b_isGood = _result.isSuccess;
                if (!b_isGood)
                {
                    i_code = Convert.ToInt32(_result.errCode);
                    s_result = string.Format("申请单号:{0} 操作出现异常 {1}", rpEntity.incident_id, _result.message);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                
                #region 写入数据库
                //写入数据库主表
                b_isGood = _BusinessLogsticBase.IsMainInsGoodByID(_outWTB_YEWUZB);
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入子表
                b_isGood = _BusinessLogsticBase.IsChildInsGoodByResult(_outWTB_GUOHUXX, s_incident_type);////需修改成string 类型
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_GUOHUXX表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入证件列表
                if (b_isGood)
                {
                    if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                    {
                        b_isGood = _BusinessLogsticBase.IsInsertCertListGood(rpEntity.CertList, _outWTB_YEWUZB);
                        if (!b_isGood)
                        {
                            i_code = 12;
                            s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 证件列表数和成功写入WTB_WENJIANXX表记录数不符", rpEntity.incident_id);
                            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            goto last;
                        }
                        else
                        {
                            i_code = 200;
                            s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                            if (STR_CURRENT_COMPANY == "PDWLY" || STR_CURRENT_COMPANY == "TRUE")//判断当前公司是否为威立雅
                            {
                                string kehulx=rpEntity.custom_type=="01"?"0":"1";
                                string zhengjianmc = "";
                                string zhengjianlx = _BusinessLogsticBase.getZhengJianLX(rpEntity.id_type, out zhengjianmc);
                                string dianhua = rpEntity.comm_rte_type_cd == "固定电话" ? rpEntity.contact_value : "";
                                string shouji = rpEntity.comm_rte_type_cd == "手机" ? rpEntity.contact_value : "";
                                string s_hm = rpEntity.business_type == "14" ? rpEntity.new_entity_name : rpEntity.company_name;
                                DataTable dt_bgxx = _AccessDataBase.KEHUXXBG("0", rpEntity.card_id, kehulx, zhengjianlx, rpEntity.id_nbr, s_hm, rpEntity.email, rpEntity.applicant, dianhua, shouji, "一网通办", rpEntity.incident_id, null);
                                if (dt_bgxx.Rows[0][0].ToString() != "00|")
                                {
                                    i_code = 12;
                                    s_result = string.Format("申请单号:{0} 办理失败", rpEntity.incident_id);
                                    s_message.AppendFormat("申请单号:{0} 办理失败", rpEntity.incident_id);
                                    _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                                    goto last;
                                }
                            }
                        }
                    }
                    else
                    {
                        i_code = 200;
                        s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                        s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                        if (STR_CURRENT_COMPANY == "PDWLY" || STR_CURRENT_COMPANY == "TRUE")//判断当前公司是否为威立雅
                        {
                            string kehulx = rpEntity.custom_type == "01" ? "0" : "1";
                            string zhengjianmc = "";
                            string zhengjianlx = _BusinessLogsticBase.getZhengJianLX(rpEntity.cert_type, out zhengjianmc);
                            string dianhua = rpEntity.comm_rte_type_cd == "固定电话" ? rpEntity.contact_value : "";
                            string shouji = rpEntity.comm_rte_type_cd == "手机" ? rpEntity.contact_value : "";
                            string s_hm = rpEntity.business_type == "14" ? rpEntity.new_entity_name : rpEntity.company_name;
                            DataTable dt_bgxx = _AccessDataBase.KEHUXXBG("0", rpEntity.card_id, kehulx, zhengjianlx, rpEntity.id_nbr, s_hm, rpEntity.email, rpEntity.applicant, dianhua, shouji, "一网通办", rpEntity.incident_id, null);
                            if (dt_bgxx.Rows[0][0].ToString() != "00|")
                            {
                                i_code = 12;
                                s_result = string.Format("申请单号:{0} 办理失败", rpEntity.incident_id);
                                s_message.AppendFormat("申请单号:{0} 办理失败", rpEntity.incident_id);
                                _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                                _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                                goto last;
                            }
                        }
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                i_code = 12;
                s_result = string.Format("申请单号：{0} 操作出现异常", rpEntity.incident_id);
                s_message.AppendFormat("申请单号：{0}操作失败,错误：{1}", rpEntity.incident_id, ex.Message);
                _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                goto last;
            }
            finally
            {
                //记日志
                LogUtil.Info(s_message.ToString());
            }
        last:
            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
            _XiangYingEntity.incident_id = rpEntity.incident_id;
            body = JsonConvert.SerializeObject(_XiangYingEntity);
            LogUtil.Info("Transfer方法返回" + S_IP + "结果：" + body);
            return _XiangYingEntity;
        }

        /// <summary>
        /// 实名制
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <returns></returns>
        public XiangYingEntity RealName(RealNameEntity rpEntity, string S_IP)
        {
            #region 定义变量
            string STR_CURRENT_COMPANY = ConfigurationManager.AppSettings["CURRENT_COMPANY"];
            int i_WsNo = (int)Web_Service_Name.RealName;//接口名称在枚举中对应的编号
            int i_code = 0;
            bool b_isGood = true;
            string s_incident_type = rpEntity.business_type;//此处为incident_type，暂时设置为17
            string s_result = string.Empty;//记录操作结果
            string body = "";
            StringBuilder s_message = new StringBuilder();
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_GUOHUXX _outWTB_GUOHUXX = new WTB_GUOHUXX();
            XiangYingEntity _XiangYingEntity = new XiangYingEntity();
            #endregion

            try
            {
                #region 记录参数
                //s_message.Append(_BusinessLogsticBase.GetParameterByMethod(i_WsNo, rpEntity));
                body = JsonConvert.SerializeObject(rpEntity);
                LogUtil.Info("RealName方法接收" + S_IP + "请求：" + body);
                #endregion

                #region 验证参数
                if (string.IsNullOrEmpty(rpEntity.incident_id)) { i_code = 11; s_result = "申请单唯一ID" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.apply_no)) { i_code = 11; s_result = "统一审批编码" + s_suffix_notEmpty; goto last; }
                //if (string.IsNullOrEmpty(rpEntity.custom_type)) { i_code = 11; s_result = "客户类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.applicant)) { i_code = 11; s_result = "申请人" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.appdate)) { i_code = 11; s_result = "申请时间" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.business_type)) { i_code = 11; s_result = "业务类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.card_id)) { i_code = 11; s_result = "销根号" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.is_transfer_order)) { i_code = 11; s_result = "是否转单" + s_suffix_notEmpty; goto last; }
                //申请转单水务公司
                if (!string.IsNullOrEmpty(rpEntity.is_transfer_order) && rpEntity.is_transfer_order == "1" && string.IsNullOrEmpty(rpEntity.shw_company_source))
                { i_code = 11; s_result = "申请转单的水务公司" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.address)) { i_code = 11; s_result = "房产地址" + s_suffix_notEmpty; goto last; }
                //////if (string.IsNullOrEmpty(rpEntity.fyly)) { i_code = 11; s_result = "反映来源" + s_suffix_notEmpty; goto last; }
                //////if (string.IsNullOrEmpty(rpEntity.fyxs)) { i_code = 11; s_result = "反映形式" + s_suffix_notEmpty; goto last; }
                //////if (string.IsNullOrEmpty(rpEntity.fyqm)) { i_code = 11; s_result = "反映区名" + s_suffix_notEmpty; goto last; }
                //////if (string.IsNullOrEmpty(rpEntity.entity_name)) { i_code = 11; s_result = "客户名称" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.id_type)) { i_code = 11; s_result = "客户证件类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.id_nbr)) { i_code = 11; s_result = "证件号码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.fczjlx)) { i_code = 11; s_result = "房产证件类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.fczjhm)) { i_code = 11; s_result = "房产证件号码" + s_suffix_notEmpty; goto last; }
                //////if (string.IsNullOrEmpty(rpEntity.comm_rte_type_cd)) { i_code = 11; s_result = "人员联系类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.contact_value)) { i_code = 11; s_result = "电话号码" + s_suffix_notEmpty; goto last; }
                //////if (string.IsNullOrEmpty(rpEntity.gyshtbh)) { i_code = 11; s_result = "合同编号" + s_suffix_notEmpty; goto last; }
                //验证列表
                if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                {
                    b_isGood = new BusinessLogsticBase().ValidateCertList(rpEntity.CertList, out s_result);
                    if (!b_isGood) { i_code = 11; goto last; }
                }
                #endregion

                #region 验证该INCIDENT_ID记录是否已存在
                b_isGood = _BusinessLogsticBase.IsIncident_IDExist(rpEntity.incident_id);
                if (!b_isGood)
                {
                    i_code = 9;
                    s_result = string.Format("申请单号:{0}已存在", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0}已存在", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                #endregion

                _BusinessLogsticBase.CreateRealNameEntity(rpEntity, out _outWTB_YEWUZB, out _outWTB_GUOHUXX);

                ResultEntity _result = searchWaterUserInfo(_outWTB_YEWUZB.CARD_ID, _outWTB_YEWUZB.BUSINESS_TYPE, "","0");//再次调用业务校验接口
                b_isGood = _result.isSuccess;
                if (!b_isGood)
                {
                    i_code = Convert.ToInt32(_result.errCode);
                    s_result = string.Format("申请单号:{0} 操作出现异常 {1}", rpEntity.incident_id, _result.message);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                #region 写入数据库
                //写入数据库主表
                b_isGood = _BusinessLogsticBase.IsMainInsGoodByID(_outWTB_YEWUZB);
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入子表
                b_isGood = _BusinessLogsticBase.IsChildInsGoodByResult(_outWTB_GUOHUXX, s_incident_type);////需修改成string 类型
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_GUOHUXX表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入证件列表
                if (b_isGood)
                {
                    if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                    {
                        b_isGood = _BusinessLogsticBase.IsInsertCertListGood(rpEntity.CertList, _outWTB_YEWUZB);
                        if (!b_isGood)
                        {
                            i_code = 12;
                            s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 证件列表数和成功写入WTB_WENJIANXX表记录数不符", rpEntity.incident_id);
                            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            goto last;
                        }
                        else
                        {
                            i_code = 200;
                            s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                            if (STR_CURRENT_COMPANY == "PDWLY" || STR_CURRENT_COMPANY == "TRUE")//判断当前公司是否为威立雅
                            {
                                string kehulx = _outWTB_YEWUZB.CUSTOM_TYPE == "01" ? "0" : "1";
                                string zhengjianmc = "";
                                string zhengjianlx = _BusinessLogsticBase.getZhengJianLX(rpEntity.id_type, out zhengjianmc);
                                //string dianhua = rpEntity.comm_rte_type_cd == "固定电话" ? rpEntity.contact_value : "";
                                //string shouji = rpEntity.comm_rte_type_cd == "手机" ? rpEntity.contact_value : "";
                                string shouji = rpEntity.contact_value;
                                DataTable dt_bgxx=_AccessDataBase.KEHUXXBG("1", rpEntity.card_id, kehulx, zhengjianlx, rpEntity.id_nbr, _outWTB_GUOHUXX.ENTITY_NAME, rpEntity.email, rpEntity.applicant, "", shouji, "一网通办", rpEntity.incident_id, null);
                                if (dt_bgxx.Rows[0][0].ToString() != "00|")
                                {
                                    i_code = 12;
                                    s_result = string.Format("申请单号:{0} 办理失败", rpEntity.incident_id);
                                    s_message.AppendFormat("申请单号:{0} 办理失败", rpEntity.incident_id);
                                    _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                                    goto last;
                                }
                            }
                        }
                    }
                    else
                    {
                        i_code = 200;
                        s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                        s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                        if (STR_CURRENT_COMPANY == "PDWLY" || STR_CURRENT_COMPANY == "TRUE")//判断当前公司是否为威立雅
                        {
                            string kehulx = _outWTB_YEWUZB.CUSTOM_TYPE == "01" ? "0" : "1";
                            string zhengjianmc = "";
                            string zhengjianlx = _BusinessLogsticBase.getZhengJianLX(rpEntity.id_type, out zhengjianmc);
                            //string dianhua = rpEntity.comm_rte_type_cd == "固定电话" ? rpEntity.contact_value : "";
                            //string shouji = rpEntity.comm_rte_type_cd == "手机" ? rpEntity.contact_value : "";
                            string shouji = rpEntity.contact_value;
                            DataTable dt_bgxx = _AccessDataBase.KEHUXXBG("1", rpEntity.card_id, kehulx, zhengjianlx, rpEntity.id_nbr, _outWTB_GUOHUXX.ENTITY_NAME, rpEntity.email, rpEntity.applicant, "", shouji, "一网通办", rpEntity.incident_id, null);
                            if (dt_bgxx.Rows[0][0].ToString() != "00|")
                            {
                                i_code = 12;
                                s_message.Clear();
                                s_message.AppendFormat("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                                s_result = string.Format("申请单号:{0} 办理失败", rpEntity.incident_id);
                                _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                                _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                                goto last;
                            }
                        }
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                i_code = 12;
                s_result = string.Format("申请单号：{0} 操作出现异常", rpEntity.incident_id);
                s_message.AppendFormat("申请单号：{0}操作失败,错误：{1}", rpEntity.incident_id, ex.Message);
                _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                goto last;
            }
            finally
            {
                //记日志
                LogUtil.Info(s_message.ToString());
            }
        last:
            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
            _XiangYingEntity.incident_id = rpEntity.incident_id;
            body = JsonConvert.SerializeObject(_XiangYingEntity);
            LogUtil.Info("RealName方法返回" + S_IP + "结果：" + body);
            return _XiangYingEntity;
        }

        /// <summary>
        /// 居民住宅总表分装
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <returns></returns>
        public XiangYingEntity WatermeterSplit(WatermeterSplitEntity rpEntity, string S_IP)
        {

            #region 定义变量
            int i_WsNo = (int)Web_Service_Name.WatermeterSplit;//接口名称在枚举中对应的编号
            int i_code = 0;
            bool b_isGood = true;
            string s_result = string.Empty;//记录操作结果
            string body = "";

            XiangYingEntity _XiangYingEntity = new XiangYingEntity();
            StringBuilder s_message = new StringBuilder();
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_JUMINZGFXX _outWTB_JUMINZGFXX = new WTB_JUMINZGFXX();

            #endregion

            try
            {
                #region 记录参数
                //s_message.Append(_BusinessLogsticBase.GetParameterByMethod(i_WsNo, rpEntity));
                body = JsonConvert.SerializeObject(rpEntity);
                LogUtil.Info("WatermeterSplit方法接收" + S_IP + "请求：" + body);
                #endregion

                #region 验证参数
                //不能为空
                if (string.IsNullOrEmpty(rpEntity.incident_id)) { i_code = 11; s_result = "申请单唯一ID" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.apply_no)) { i_code = 11; s_result = "统一审批编码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.shw_address)) { i_code = 11; s_result = "用水地址" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.applicant)) { i_code = 11; s_result = "申请人" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.appdate)) { i_code = 11; s_result = "申请时间" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.incident_type)) { i_code = 11; s_result = "申请单类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.cert_type)) { i_code = 11; s_result = "证件类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.cert_number)) { i_code = 11; s_result = "证件号码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.business_type)) { i_code = 11; s_result = "业务类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.card_id)) { i_code = 11; s_result = "销根号" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.is_transfer_order)) { i_code = 11; s_result = "是否转单" + s_suffix_notEmpty; goto last; }
                //申请转单水务公司
                if (!string.IsNullOrEmpty(rpEntity.is_transfer_order) && rpEntity.is_transfer_order == "1" && string.IsNullOrEmpty(rpEntity.shw_company_source))
                { i_code = 11; s_result = "申请转单的水务公司" + s_suffix_notEmpty; goto last; }
               // if (string.IsNullOrEmpty(rpEntity.xzq)) { i_code = 11; s_result = "行政区" + s_suffix_notEmpty; goto last; }
               // if (string.IsNullOrEmpty(rpEntity.jdz)) { i_code = 11; s_result = "街道镇" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.address)) { i_code = 11; s_result = "发生地址" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.con_name)) { i_code = 11; s_result = "联系人" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.phone)) { i_code = 11; s_result = "联系人手机" + s_suffix_notEmpty; goto last; }
                //验证列表
                if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                {
                    b_isGood = new BusinessLogsticBase().ValidateCertList(rpEntity.CertList, out s_result);
                    if (!b_isGood) { i_code = 11; goto last; }
                }
                #endregion

                #region 验证该INCIDENT_ID记录是否已存在
                b_isGood = _BusinessLogsticBase.IsIncident_IDExist(rpEntity.incident_id);
                if (!b_isGood)
                {
                    i_code = 9;
                    s_result = string.Format("申请单号:{0}已存在", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0}已存在", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                #endregion

                _BusinessLogsticBase.CreateWatermeterSplitEntity(rpEntity, out _outWTB_YEWUZB, out _outWTB_JUMINZGFXX);

                ResultEntity _result = searchWaterUserInfo(_outWTB_YEWUZB.CARD_ID, _outWTB_YEWUZB.BUSINESS_TYPE, "","0");//再次调用业务校验接口
                b_isGood = _result.isSuccess;
                if (!b_isGood)
                {
                    i_code = Convert.ToInt32(_result.errCode);
                    s_result = string.Format("申请单号:{0} 操作出现异常 {1}", rpEntity.incident_id, _result.message);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }

                #region 写入数据库
                //写入数据库主表
                b_isGood = _BusinessLogsticBase.IsMainInsGoodByID(_outWTB_YEWUZB);
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入子表
                b_isGood = _BusinessLogsticBase.IsChildInsGoodByResult(_outWTB_JUMINZGFXX, "16");////需修改成string 类型
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_JUMINZGFXX表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入证件列表
                if (b_isGood)
                {
                    if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                    {
                        b_isGood = _BusinessLogsticBase.IsInsertCertListGood(rpEntity.CertList, _outWTB_YEWUZB);
                        if (!b_isGood)
                        {
                            i_code = 12;
                            s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 证件列表数和成功写入WTB_WENJIANXX表记录数不符", rpEntity.incident_id);
                            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            goto last;
                        }
                        else
                        {
                            i_code = 200;
                            s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                        }
                    }
                    else
                    {
                        i_code = 200;
                        s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                        s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                i_code = 12;
                s_result = string.Format("申请单号：{0} 操作出现异常", rpEntity.incident_id);
                s_message.AppendFormat("申请单号：{0}操作失败,错误：{1}", rpEntity.incident_id, ex.Message);
                _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                goto last;
            }
            finally
            {
                //记日志
                LogUtil.Info(s_message.ToString());
            }
        last:
            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
            _XiangYingEntity.incident_id = rpEntity.incident_id;
            body = JsonConvert.SerializeObject(_XiangYingEntity);
            LogUtil.Info("WatermeterSplit方法返回" + S_IP + "结果：" + body);
            return _XiangYingEntity;
        }

        /// <summary>
        /// 业务受理校验  接口
        /// </summary>
        /// <param name="card_id"></param>
        /// <param name="businessType"></param>
        /// <param name="S_IP"></param>
        /// <param name="queryType">0 业务校验；1 用户信息查询</param>
        /// <returns></returns>
        public ResultEntity searchWaterUserInfo(string card_id, string businessType, string S_IP, string queryType)
        {
            ResultEntity _ResultEntity = new ResultEntity();//业务校验结果entity
            errDataEntity_New _ErrDataEntity = new errDataEntity_New();
            string body = "";
            _ResultEntity.card_id = card_id;
            _ResultEntity.isSuccess = false;
            _ResultEntity.code = 200;//HTTP状态码

            
            LogUtil.Info("searchWaterUserInfo方法接收" + S_IP + "请求：card_id:" + card_id + ";businessType:" + businessType + ";queryType:" + queryType);
            try
            {
                DataTable dt = _AccessDataBase.searchWaterUserInfo(card_id, businessType, queryType, null);
                if (dt != null && dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["ErrorInfo"].ToString().Split('|')[0] == "00")
                    {
                        _ResultEntity.isSuccess = true;
                        _ResultEntity.owner_name = (dt.Rows[0]["owner_name"] == DBNull.Value ? "" : dt.Rows[0]["owner_name"].ToString());
                        _ResultEntity.owner_idno = dt.Rows[0]["owner_idno"] == DBNull.Value ? "" : dt.Rows[0]["owner_idno"].ToString();
                        _ResultEntity.shw_address = dt.Rows[0]["shw_address"] == DBNull.Value ? "" : dt.Rows[0]["shw_address"].ToString();
                        if (dt.Rows[0]["meter_read"] != DBNull.Value)
                            _ResultEntity.meter_read = Convert.ToInt32(dt.Rows[0]["meter_read"].ToString());
                        _ResultEntity.owner_id_type = dt.Rows[0]["owner_id_type"] == DBNull.Value ? "" : dt.Rows[0]["owner_id_type"].ToString();

                        _ResultEntity.has_zbyw = dt.Rows[0]["has_zbyw"] == DBNull.Value ? "" : dt.Rows[0]["has_zbyw"].ToString();
                        _ResultEntity.zbywlx = dt.Rows[0]["zbywlx"] == DBNull.Value ? "" : dt.Rows[0]["zbywlx"].ToString();

                        _ResultEntity.has_multipop = dt.Rows[0]["has_multipop"] == DBNull.Value ? "" : dt.Rows[0]["has_multipop"].ToString();

                        _ResultEntity.total_money = dt.Rows[0]["total_money"] == DBNull.Value ? "" : dt.Rows[0]["total_money"].ToString();
                        _ResultEntity.total_wyj = dt.Rows[0]["total_wyj"] == DBNull.Value ? "" : dt.Rows[0]["total_wyj"].ToString();
                        _ResultEntity.cred_level = dt.Rows[0]["cred_level"] == DBNull.Value ? "" : dt.Rows[0]["cred_level"].ToString();

                        _ResultEntity.fptt = dt.Rows[0]["fptt"] == DBNull.Value ? "" : dt.Rows[0]["fptt"].ToString();
                        _ResultEntity.lately_date = dt.Rows[0]["lately_date"] == DBNull.Value ? "" : dt.Rows[0]["lately_date"].ToString();
                        _ResultEntity.owner_phone = dt.Rows[0]["owner_phone"] == DBNull.Value ? "" : dt.Rows[0]["owner_phone"].ToString();
                        _ResultEntity.send_address = dt.Rows[0]["send_address"] == DBNull.Value ? "" : dt.Rows[0]["send_address"].ToString();
                        _ResultEntity.yb = dt.Rows[0]["yb"] == DBNull.Value ? "" : dt.Rows[0]["yb"].ToString();
                        _ResultEntity.invoice_push = dt.Rows[0]["invoice_push"] == DBNull.Value ? "" : dt.Rows[0]["invoice_push"].ToString();
                        _ResultEntity.card_id_type = dt.Rows[0]["card_id_type"] == DBNull.Value ? "" : dt.Rows[0]["card_id_type"].ToString();
                        _ResultEntity.reserve1 = dt.Rows[0]["reserve1"] == DBNull.Value ? "" : dt.Rows[0]["reserve1"].ToString();
                        _ResultEntity.reserve2 = dt.Rows[0]["reserve2"] == DBNull.Value ? "" : dt.Rows[0]["reserve2"].ToString();
                        _ResultEntity.reserve3 = dt.Rows[0]["reserve3"] == DBNull.Value ? "" : dt.Rows[0]["reserve3"].ToString();
                        _ErrDataEntity.applyNo = "";
                        _ErrDataEntity.businessType = "";
                        _ErrDataEntity.source = "";
                        _ErrDataEntity.lastApplyTime = "";
                        _ErrDataEntity.userNoLength = "";
                        _ErrDataEntity.userNoType = "";
                        _ResultEntity.errData = _ErrDataEntity;
                        goto last;
                    }
                    else
                    {
                        _ResultEntity.isSuccess = false;
                        _ResultEntity.code = 500;
                        string errCode = dt.Rows[0]["ErrorInfo"].ToString().Split('|')[0];
                        _ResultEntity.errCode = dt.Rows[0]["ErrorInfo"].ToString().Split('|')[0];
                        string message = dt.Rows[0]["ErrorInfo"].ToString().Split('|')[1];
                        _ResultEntity.message = dt.Rows[0]["ErrorInfo"].ToString().Split('|')[1];
                        _ErrDataEntity.businessType = "";
                        _ErrDataEntity.applyNo = "";

                        _ErrDataEntity.source = "";
                        _ErrDataEntity.lastApplyTime = "";
                        _ErrDataEntity.userNoLength = "";
                        _ErrDataEntity.userNoType = "";
                        if (errCode == "02")
                        {
                            //查询未完结业务相关信息

                            DataTable dt2 = _AccessDataBase.searchWWJYWInfo(card_id, businessType, null);
                            if (dt2 != null && dt2.Rows.Count > 0)
                            {
                                _ErrDataEntity.businessType = dt2.Rows[0]["msg"].ToString();
                            }
                        }
                        if (errCode == "15")
                        {
                            //相同业务受理中
                            DataTable dt2 = _AccessDataBase.searchXiangTongYWInfo(card_id, businessType, null);
                            if (dt2 != null && dt2.Rows.Count > 0)
                            {
                                _ErrDataEntity.lastApplyTime = dt2.Rows[0]["lastApplyTime"].ToString();
                                _ErrDataEntity.source = dt2.Rows[0]["source"].ToString();
                            }
                        }
                        if (errCode == "01")
                        {
                            _ErrDataEntity.userNoLength = "11";
                            _ErrDataEntity.userNoType = "用户号";
                        }
                        _ResultEntity.errData = _ErrDataEntity;
                        goto last;
                    }
                }
                else
                {
                    _ResultEntity.code = 500;
                    _ResultEntity.errCode = "07";
                    _ResultEntity.message = "参数值错误";
                    _ErrDataEntity.applyNo = "";
                    _ErrDataEntity.businessType = "";
                    _ErrDataEntity.source = "";
                    _ErrDataEntity.lastApplyTime = "";
                    _ResultEntity.errData = _ErrDataEntity;
                    goto last;
                }
            }
            catch (Exception ex)
            {
                _ResultEntity.code = 500;
                _ResultEntity.errCode = "13";
                _ResultEntity.message = "数据库连接失败";
                _ErrDataEntity.applyNo = "";
                _ErrDataEntity.businessType = "";
                _ErrDataEntity.source = "";
                _ErrDataEntity.lastApplyTime = "";
                _ResultEntity.errData = _ErrDataEntity;
                LogUtil.Info(ex.Message.ToString());
                goto last;
            }
            finally
            {
                //记日志
                string s_message = _ResultEntity.message;
            }
        last:
            body = JsonConvert.SerializeObject(_ResultEntity);
            LogUtil.Info("searchWaterUserInfo方法返回" + S_IP + "结果：" + body);
            return _ResultEntity;
        }

        /// <summary>
        /// 获取地址 接口
        /// </summary>
        /// <param name="card_id"></param>
        /// <returns></returns>
        public AddressResultEntity getAddress(string card_id, string S_IP)
        {
            AddressResultEntity _AddressResult = new AddressResultEntity();
            _AddressResult.code = 200;
            string body = "";

            LogUtil.Info("getAddress方法接收" + S_IP + "请求：card_id:" + card_id);

            try
            {
                DataTable dt = _AccessDataBase.getAddress(card_id, null);

                _AddressResult.isSuccess = false;
                if (dt != null && dt.Rows.Count > 0)
                {
                    _AddressResult.isSuccess = true;
                    _AddressResult.shw_address = dt.Rows[0]["S_DZ"].ToString();
                }
                else
                {
                    _AddressResult.errCode = "01";
                    _AddressResult.message = "销根号不存在";
                }
            }
            catch (Exception ex)
            {
                _AddressResult.errCode = "13";
                _AddressResult.code = 500;
                _AddressResult.message = ex.Message;
                throw ex;
            }
            body = JsonConvert.SerializeObject(_AddressResult);
            LogUtil.Info("getAddress方法返回" + S_IP + "结果：" + body);
            return _AddressResult;
        }

        public ArrearsBillResultEntity queryArrearsBill(queryArrearsBillEntity rpEntity, string S_IP)
        {

            ArrearsBillResultEntity queryArrearsBill = new ArrearsBillResultEntity();
            string body = JsonConvert.SerializeObject(rpEntity);
            LogUtil.Info("queryArrearsBill方法接收" + S_IP + "请求:" + body);
            body = "";

            #region 构建返回数据
            queryArrearsBill.isSuccess = true;
            queryArrearsBill.code = 200;
            queryArrearsBill.errCode = "";
            queryArrearsBill.message = "";
            queryArrearsBill.re_code = "00";
            queryArrearsBill.tran_code = rpEntity.tran_code; //返回请求字段
            queryArrearsBill.bank_no = rpEntity.bank_no;    //返回请求字段
            queryArrearsBill.oper_id = rpEntity.oper_id;    //返回请求字段
            queryArrearsBill.fqfs = rpEntity.fqfs;          //返回请求字段
            queryArrearsBill.user_no = rpEntity.user_no;    //返回请求字段
            queryArrearsBill.flow_no = rpEntity.flow_no;    //返回请求字段
            List<Billings> _bills = new List<Billings>();
            //_bills.Add(new Billings());

            #endregion
            try
            {
                #region 数值校验
                if (rpEntity.user_no == "" && rpEntity.bar_code == "")
                {
                    queryArrearsBill.isSuccess = false;
                    queryArrearsBill.errCode = "07";
                    queryArrearsBill.message = "card_id与bar_code不能同时为空";
                    goto last;
                }
                if (rpEntity.tran_code == "11" && rpEntity.date_scope == "1" && string.IsNullOrWhiteSpace(rpEntity.start_date))
                {
                    queryArrearsBill.isSuccess = false;
                    queryArrearsBill.errCode = "07";
                    queryArrearsBill.message = "时间段查询，起始年月不能为空";
                    goto last;
                }
                if (rpEntity.tran_code == "11" && rpEntity.date_scope == "0" && string.IsNullOrWhiteSpace(rpEntity.zwny))//账单查询，且是单月查看类型，则账务年月不能为空
                {
                    queryArrearsBill.isSuccess = false;
                    queryArrearsBill.errCode = "07";
                    queryArrearsBill.message = "单月查询，账务年月不能为空";
                    goto last;
                }
                if (!String.IsNullOrWhiteSpace(rpEntity.zwny))//账务年月、开始日期、结束日期 格式校验
                {
                    string msgstr = _BusinessLogsticBase.yearAndMonthPanDuan(rpEntity.zwny.Trim(), "zwny");
                    if (msgstr != "00|")
                    {
                        queryArrearsBill.isSuccess = false;
                        queryArrearsBill.errCode = msgstr.Split('|')[0];
                        queryArrearsBill.message = msgstr.Split('|')[1];
                        goto last;
                    }
                }
                if (!String.IsNullOrWhiteSpace(rpEntity.start_date))//账务年月、开始日期、结束日期 格式校验
                {
                    string msgstr = _BusinessLogsticBase.yearAndMonthPanDuan(rpEntity.start_date.Trim(), "start_date");
                    if (msgstr != "00|")
                    {
                        queryArrearsBill.isSuccess = false;
                        queryArrearsBill.errCode = msgstr.Split('|')[0];
                        queryArrearsBill.message = msgstr.Split('|')[1];
                        goto last;
                    }
                }
                if (!String.IsNullOrWhiteSpace(rpEntity.end_date))//账务年月、开始日期、结束日期 格式校验
                {
                    string msgstr = _BusinessLogsticBase.yearAndMonthPanDuan(rpEntity.end_date.Trim(), "end_date");
                    if (msgstr != "00|")
                    {
                        queryArrearsBill.isSuccess = false;
                        queryArrearsBill.errCode = msgstr.Split('|')[0];
                        queryArrearsBill.message = msgstr.Split('|')[1];
                        goto last;
                    }
                }

                if (!String.IsNullOrWhiteSpace(rpEntity.start_date) && !String.IsNullOrWhiteSpace(rpEntity.end_date))
                {
                    int start = Convert.ToInt32(rpEntity.start_date.Trim());
                    int end = Convert.ToInt32(rpEntity.end_date.Trim());
                    if (start >= end)
                    {
                        queryArrearsBill.isSuccess = false;
                        queryArrearsBill.errCode = "07";
                        queryArrearsBill.message = "开始日期不能大于结束日期";
                        goto last;
                    }
                }
                if (String.IsNullOrEmpty(rpEntity.user_no.Trim()))
                {
                    rpEntity.user_no = rpEntity.bar_code.Substring(0, 9);
                }
                
                #endregion
                DataSet ds = _AccessDataBase.querybill(rpEntity.tran_code, rpEntity.date_scope, rpEntity.bank_no, rpEntity.oper_id, rpEntity.fqfs, rpEntity.user_no, rpEntity.zwny, rpEntity.bar_code, rpEntity.flow_no, rpEntity.start_date, rpEntity.end_date);
                if (ds.Tables[0].Rows[0]["re_code"].ToString() != "00")
                {
                    queryArrearsBill.re_code = ds.Tables[0].Rows[0]["re_code"].ToString();
                    goto last;
                }
                foreach (DataRow item in ds.Tables[1].Rows)
                {
                    Billings _bill = new Billings();
                    _bill.feeid = item["feeid"].ToString();
                    _bill.user_name = item["user_name"].ToString();
                    _bill.pay_agent = item["pay_agent"].ToString();
                    _bill.pay_source = item["pay_source"].ToString();
                    _bill.year = item["year"].ToString();
                    _bill.month = item["month"].ToString();
                    _bill.billingdate = item["billingdate"].ToString();
                    _bill.readdate = item["readdate"].ToString();
                    _bill.money = item["money"].ToString();
                    _bill.n_weiyuej = item["n_weiyuej"].ToString();
                    _bill.s_zhangdantxm = item["s_zhangdantxm"].ToString();
                    _bill.i_zhangwuny = item["i_zhangwuny"].ToString();
                    _bill.pay_time = item["pay_time"].ToString();
                    _bill.i_cc = item["i_cc"].ToString();
                    _bill.i_shoufei = item["i_shoufei"].ToString();
                    _bill.i_zhangdanzt = item["i_zhangdanzt"].ToString();
                    _bills.Add(_bill);
                }
            }
            catch (Exception ex)
            {
                queryArrearsBill.errCode = "13";
                queryArrearsBill.code = 500;
                queryArrearsBill.message = "数据库连接失败";
                LogUtil.Info(ex.Message.ToString());
                goto last;
            }
            finally
            {
                //记日志
                string s_message = queryArrearsBill.message;
            }
        last:
            queryArrearsBill.Billings = _bills;
            body = JsonConvert.SerializeObject(queryArrearsBill);
            LogUtil.Info("queryArrearsBill方法返回" + S_IP + "结果：" + body);
            return queryArrearsBill;
        }

        /// <summary>
        /// 一网通办提供的更新状态 接口
        /// </summary>
        /// <param name="leixing">业务类型</param>
        /// <param name="body"></param>
        /// <returns></returns>
        public string updateIncidentStatus(string leixing, string body)
        {
            string strURL = "";
            string strMethod = "";
            string result = "";
            LogUtil.Info("updateIncidentStatus请求参数：" + body);
            try
            {
                DataTable dt = _BusinessLogsticBase.JsonToDataTable(body);
                string incident_id = dt.Rows[0]["incident_id"].ToString();
                string jsstatus = dt.Rows[0]["status"].ToString();
                string jsresult = dt.Rows[0]["result"].ToString();
                string oper_id = dt.Rows[0]["oper_id"].ToString();
                string description = dt.Rows[0]["description"].ToString();
                DataSet ds = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "UPDATE;WTB_GONGDANHUITIAN;0;" + incident_id + ";" + jsstatus + ";" + jsresult + ";" + oper_id + ";" + description, "");

                if (ds.Tables[0].Rows[0]["MSGCODE"].ToString() != "00|")
                {
                    IncidentStatusReturnEntity _result = new IncidentStatusReturnEntity();
                    _result.incidentId = incident_id;
                    _result.isSuccess = "false";
                    _result.code = "500";
                    _result.errCode = ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[0];
                    _result.message = ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[1];
                    result = JsonConvert.SerializeObject(_result);
                    LogUtil.Info("CSMS申请单状态更新异常", result);
                    return result;
                }
                if (ds.Tables[0].Rows[0]["MESSAGE"].ToString().Length > 5)
                {
                    var abcObject = new
                    {
                        incident_id = incident_id,
                        shw_company = "PDXQZLS",
                        oper_id = dt.Rows[0]["oper_id"].ToString(),
                        status = dt.Rows[0]["status"].ToString(),
                        result = dt.Rows[0]["result"].ToString(),
                        description = ds.Tables[0].Rows[0]["MESSAGE"].ToString()
                    };
                    body = JsonConvert.SerializeObject(abcObject);
                    LogUtil.Info("updateIncidentStatus更新请求参数：" + body);
                }
                switch (leixing)
                {
                    case "04":
                    case "05":
                    case "06":
                    case "07":
                    case "08":
                    case "09":
                    case "10":
                    case "11":
                    case "12":
                    case "13":
                        strURL = ConfigurationManager.AppSettings["URL_BAOXIU_WTB"];
                        strMethod = ConfigurationManager.AppSettings["METHODNAME_BAOXIU_WTB"];
                        break;
                    default:
                        strURL = ConfigurationManager.AppSettings["URL_BAOXIU_WTB"];
                        strMethod = ConfigurationManager.AppSettings["METHODNAME_BAOXIU_WTB"];
                        break;
                }

                //LogUtil.Info("调用一网通办地址：" + strURL + "，方法：" + strMethod + "，" + body);
                result = _BusinessLogsticBase.QueryPostHttpsWebService(strURL, strMethod, body);
                LogUtil.Info("返回结果 ，" + result+"|"+ConfigurationManager.AppSettings["WTBONLINE"].ToString());
                if (ConfigurationManager.AppSettings["WTBONLINE"].ToString() == "0")
                {
                    IncidentStatusReturnEntity _resultnew = new IncidentStatusReturnEntity();
                    _resultnew.isSuccess = "true";
                    _resultnew.code = "200";
                    _resultnew.errCode = "OK";
                    result = JsonConvert.SerializeObject(_resultnew);
                    LogUtil.Info("返回结果新321 ，" + result);
                }
            }
            catch (Exception ex)
            {

                IncidentStatusReturnEntity _result = new IncidentStatusReturnEntity();
                LogUtil.Info("返回结果新标记2，" + ConfigurationManager.AppSettings["WTBONLINE"].ToString());
                if (ConfigurationManager.AppSettings["WTBONLINE"].ToString() == "0")
                {
                    _result.isSuccess = "true";
                    _result.code = "200";
                    _result.errCode = "OK";
                }
                else
                {
                    _result.isSuccess = "false";
                    _result.code = "500";
                    _result.errCode = "01";
                    _result.message = "接口异常";
                }
                if (ex.Message == "The remote server returned an error: (500) Internal Server Error.")
                {
                    _result.isSuccess = "true";
                    _result.code = "200";
                    _result.errCode = "OK";
                }

                LogUtil.Info("发生异常 ，" + ex.Message);
                result = JsonConvert.SerializeObject(_result);
                LogUtil.Info("返回结果新NEW1，" + result);
                return result;

            }
            return result;
        }

        /// <summary>
        /// 一网通办提供的转单 接口
        /// </summary>
        /// <param name="leixing">业务类型</param>
        /// <param name="body"></param>
        /// <returns></returns>
        public string transferIncident(string leixing, string body)
        {
            string strURL = "";
            string strMethod = "";
            string result = "";
            LogUtil.Info("transferIncident请求参数：" + body);
            try
            {
                DataTable dt = _BusinessLogsticBase.JsonToDataTable(body);
                string incident_id = dt.Rows[0]["incident_id"].ToString();
                string jsstatus = "";
                string jsresult = "";
                DataSet ds=_AccessDataBase.GetParamsDataSource("<PROCEDURE>", "UPDATE;WTB_GONGDANHUITIAN;1;" + incident_id + ";" + jsstatus + ";" + jsresult, "");

                if (ds.Tables[0].Rows[0]["MSGCODE"].ToString() != "00|")
                {
                    IncidentStatusReturnEntity _result = new IncidentStatusReturnEntity();
                    _result.incidentId = incident_id;
                    _result.isSuccess = "false";
                    _result.code = "500";
                    _result.errCode = ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[0];
                    _result.message = ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[1];
                    result = JsonConvert.SerializeObject(_result);
                    LogUtil.Info("CSMS申请单状态更新异常", result);
                    return result;
                }
                strURL = ConfigurationManager.AppSettings["URL_BAOXIU_WTB"];
                strMethod = ConfigurationManager.AppSettings["METHODNAME_ZHUANDAN_WTB"];

                //LogUtil.Info("调用一网通办地址：" + strURL + "，方法：" + strMethod + "，" + body);
                result = _BusinessLogsticBase.QueryPostHttpsWebService(strURL, strMethod, body);
                LogUtil.Info("返回结果 ，" + result);               
                if (ConfigurationManager.AppSettings["WTBONLINE"] == "0")
                {
                    IncidentStatusReturnEntity _resultnew = new IncidentStatusReturnEntity();
                    _resultnew.isSuccess = "true";
                    _resultnew.code = "200";
                    result = JsonConvert.SerializeObject(_resultnew);
                }
            }
            catch (Exception ex)
            {
                IncidentStatusReturnEntity _result = new IncidentStatusReturnEntity();
                if (ConfigurationManager.AppSettings["WTBONLINE"] == "0")
                {
                    _result.isSuccess = "true";
                    _result.code = "200";
                }
                else
                {
                    _result.isSuccess = "false";
                    _result.code = "500";
                    _result.errCode = "01";
                    _result.message = "接口异常";
                }

                LogUtil.Info("发生异常 ，" + ex.Message);
                result = JsonConvert.SerializeObject(_result);
                return result;

            }
            return result;
        }

        /// <summary>
        /// 延期接口
        /// </summary>
        /// <param name="leixing"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        public string incidentDefer(string leixing, string body)
        {
            string strURL = "";
            string strMethod = "";
            string result = "";
            try
            {
                LogUtil.Info("incidentDefer请求参数：" + body);
                DataTable dt = _BusinessLogsticBase.JsonToDataTable(body);
                string incident_id = dt.Rows[0]["incident_id"].ToString();
                string jsstatus = "";
                string jsresult = "";
                DataSet ds=_AccessDataBase.GetParamsDataSource("<PROCEDURE>", "UPDATE;WTB_GONGDANHUITIAN;2;" + incident_id + ";" + jsstatus + ";" + jsresult, "");

                if (ds.Tables[0].Rows[0]["MSGCODE"].ToString() != "00|")
                {
                    IncidentStatusReturnEntity _result = new IncidentStatusReturnEntity();
                    _result.incidentId = incident_id;
                    _result.isSuccess = "false";
                    _result.code = "500";
                    _result.errCode = ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[0];
                    _result.message = ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[1];
                    result = JsonConvert.SerializeObject(_result);
                    LogUtil.Info("CSMS申请单状态更新异常", result);
                    return result;
                }
                switch (leixing)
                {
                    case "04":
                    case "05":
                    case "06":
                    case "07":
                    case "08":
                    case "09":
                    case "10":
                    case "11":
                    case "12":
                    case "13":
                        strURL = ConfigurationManager.AppSettings["URL_YANQI_WTB"];
                        strMethod = ConfigurationManager.AppSettings["METHODNAME_YANQI_WTB"];
                        break;
                    default:
                        strURL = ConfigurationManager.AppSettings["URL_YANQI_WTB"];
                        strMethod = ConfigurationManager.AppSettings["METHODNAME_YANQI_WTB"];
                        break;
                }
                //LogUtil.Info("调用一网通办地址：" + strURL + "，方法：" + strMethod + "，" + body);
                result = _BusinessLogsticBase.QueryPostHttpsWebService(strURL, strMethod, body);
                LogUtil.Info("返回结果 ，" + result); 
            }
            catch (Exception ex)
            {

                IncidentStatusReturnEntity _result = new IncidentStatusReturnEntity();
                if (ConfigurationManager.AppSettings["WTBONLINE"] == "0")
                {
                    _result.isSuccess = "true";
                    _result.code = "200";
                }
                else
                {
                    _result.isSuccess = "false";
                    _result.code = "500";
                    _result.errCode = "01";
                    _result.message = "接口异常";
                }

                LogUtil.Info("发生异常 ，" + ex.Message);
                result = JsonConvert.SerializeObject(_result);
                return result;

            }
            return result;
        }

        public string UPLOADCAHETONGCA(string V_S_CID, string V_S_HETONGBH, string V_S_HM, string V_S_JH, string V_D_DIANHUA, string V_S_ZHENGJIANID, out string filename, out string msg)
        {

            return _BusinessLogsticBase.CreateLocalPDFLOCAL(V_S_CID, V_S_HETONGBH, V_S_HM, V_S_JH, V_D_DIANHUA, V_S_ZHENGJIANID, out filename, out msg);
        }

        public bool UploadHeTong(string incident_id, out string msg)
        {
            bool _result;
            string localfilename = "";
            string rootPath = ConfigurationManager.AppSettings["SFTP_PATH"];
            string HETONGPATH_NEW = ConfigurationManager.AppSettings["HETONGPATH_NEW"];
            string YEAR = "";
            string MONTH = "";
            string INCIDENT_TYPE = "";
            string APPLY_NO = "";
            //_result = _BusinessLogsticBase.CreateLocalPDF(incident_id, out localfilename, out  msg);
            _result = _BusinessLogsticBase.CreateLocalPDFN(incident_id, out localfilename, out  msg, out YEAR, out MONTH, out INCIDENT_TYPE, out APPLY_NO);

            if (INCIDENT_TYPE == "McsItemType.RepairUnseal")
            {
                return UploadHeTong_XBQF(ref _result, localfilename, incident_id, APPLY_NO);
            }

            #region 上传到CSMSFTP
            if (_result)
            {
                LogUtil.Info("本地合同创建成功...{0}", localfilename);
                //获取上级文件夹
                string[] str1 = System.IO.Path.GetDirectoryName(localfilename).ToString().Split('\\');
                string dic = str1[str1.Length - 1];
              
                _result = _BusinessLogsticBase.UploadFile2CSMS(dic, localfilename);
                if (_result)
                {

                    //_BusinessLogsticBase.
                    string _CSMS_PATH = ConfigurationManager.AppSettings["CSMS_PATH"];
                    string wenjianlj = "//" + _CSMS_PATH + "/" + dic + "/" + System.IO.Path.GetFileName(localfilename);
                    DataSet ds = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "INSERT;WTB_UPLOADHETONG;" + incident_id + ";" + wenjianlj, "");
                    if (ds.Tables[0].Rows[0]["MSGCODE"].ToString() == "00|")
                    {
                        _result = true;
                    }
                    else
                    {
                        LogUtil.Info("CSMS上传合同成功...{0}..{1}", "文件上传至CSMS异常", _result);
                        msg = "";
                        _result = true;
                    }
                }
            }
            #endregion
            LogUtil.Info("CSMS上传合同成功...{0}..{1}", localfilename, _result);
            #region 上传到网通办FTP

            string _AUTOUPLOAD = ConfigurationManager.AppSettings["AUTOUPLOAD"];
            if (_AUTOUPLOAD == "TRUE")
            {
                string Environment = ConfigurationManager.AppSettings["Environment"];
                if (Environment == "TEST")
                {
                    string[] str1 = System.IO.Path.GetDirectoryName(localfilename).ToString().Split('\\');
                    string dic = str1[str1.Length - 1];
                    FtpWeb _ftpweb = new FtpWeb(ConfigurationManager.AppSettings["FTP_IP"],"", ConfigurationManager.AppSettings["FTP_ACCOUNT"], ConfigurationManager.AppSettings["FTP_PWD"]);
            
                    CreateDirectory(ConfigurationManager.AppSettings["SFTP_PATH"] + "/" + YEAR + "/" + Convert.ToInt32(MONTH).ToString() + "/" + INCIDENT_TYPE + "/" + str1[str1.Length - 1].ToString());
                    _ftpweb.ftpURI = _ftpweb.ftpURI + ConfigurationManager.AppSettings["SFTP_PATH"] + "/" + YEAR + "/" + Convert.ToInt32(MONTH).ToString() + "/" + INCIDENT_TYPE + "/" + str1[str1.Length - 1].ToString()+"/";

                    _ftpweb.Upload(localfilename);
                    //获取上级文件夹
                    //try
                    //{
                    //    string[] str1 = System.IO.Path.GetDirectoryName(localfilename).ToString().Split('\\');
                    //    string dic = str1[str1.Length - 1];

                    //    //FtpWeb _ftpweb = new FtpWeb(ConfigurationManager.AppSettings["SFTP_IP"] + ":" + ConfigurationManager.AppSettings["SFTP_PORT"], ConfigurationManager.AppSettings["SFTP_PATH"], ConfigurationManager.AppSettings["SFTP_ACCOUNT"], ConfigurationManager.AppSettings["SFTP_PWD"]);
                    //    FtpWeb _ftpweb = new FtpWeb(ConfigurationManager.AppSettings["FTP_IP"], ConfigurationManager.AppSettings["SFTP_PATH"], ConfigurationManager.AppSettings["SFTP_ACCOUNT"], ConfigurationManager.AppSettings["SFTP_PWD"]);
                    //    LogUtil.Info("下载文件:" + ConfigurationManager.AppSettings["FTP_IP"] + ConfigurationManager.AppSettings["FTP_ACCOUNT"] + "|" + ConfigurationManager.AppSettings["FTP_PWD"] + "|" + entity.data.pdfSftpPath.Replace("/" + Filename, "").Substring(1) + "|" + Filename + "到本地。");

                    //    _ftpweb.SFTPOperation(ConfigurationManager.AppSettings["FTP_IP"], "16022", ConfigurationManager.AppSettings["SFTP_ACCOUNT"], ConfigurationManager.AppSettings["SFTP_PWD"]);

                    //    LogUtil.Info("ftpURI:{0}", _ftpweb.ftpURI);
                    //    _ftpweb.Put(localfilename, ConfigurationManager.AppSettings["SFTP_PATH"] + "/" + str1[str1.Length - 1].ToString(), System.IO.Path.GetFileName(localfilename));
                    //}
                    //catch(Exception ex)
                    //{
                    //    LogUtil.Info("WTB上传合同失败...{0}", ex.Message);
                    //}
                }
                else
                {
                try
                {
                    string[] str1 = System.IO.Path.GetDirectoryName(localfilename).ToString().Split('\\');
                    string dic = str1[str1.Length - 1];

                    FtpWeb _ftpweb = new FtpWeb(ConfigurationManager.AppSettings["SFTP_IP"] + ":" + ConfigurationManager.AppSettings["SFTP_PORT"], ConfigurationManager.AppSettings["SFTP_PATH"], ConfigurationManager.AppSettings["SFTP_ACCOUNT"], ConfigurationManager.AppSettings["SFTP_PWD"]);
                    _ftpweb.SFTPOperation(ConfigurationManager.AppSettings["SFTP_IP"], "16022", ConfigurationManager.AppSettings["SFTP_ACCOUNT"], ConfigurationManager.AppSettings["SFTP_PWD"]);

                    LogUtil.Info("WTB上传合同路径...{0}", ConfigurationManager.AppSettings["SFTP_IP"] + "|" + ConfigurationManager.AppSettings["SFTP_ACCOUNT"] +"|"+ConfigurationManager.AppSettings["SFTP_PWD"]                      );
                    LogUtil.Info("ftpURI:{0}", _ftpweb.ftpURI);
                    try
                    {
                        //ConfigurationManager.AppSettings["SFTP_PATH"] + "/" + str1[str1.Length - 1].ToString()
                        _ftpweb.Put(localfilename, ConfigurationManager.AppSettings["SFTP_PATH"] + "/" + YEAR + "/" + Convert.ToInt32(MONTH).ToString() + "/" + INCIDENT_TYPE + "/" + str1[str1.Length - 1].ToString(), System.IO.Path.GetFileName(localfilename));
                        //_ftpweb.Put(localfilename, ConfigurationManager.AppSettings["SFTP_PATH"] + "/" + str1[str1.Length - 1].ToString(), System.IO.Path.GetFileName(localfilename));
                    }
                    catch (Exception ex)
                    {
                        LogUtil.Info("ftpURIException:{0}", ex.Message);
                    }
                    //FtpWeb _ftpweb = new FtpWeb(ConfigurationManager.AppSettings["FTP_IP"], ConfigurationManager.AppSettings["SFTP_PATH"], ConfigurationManager.AppSettings["SFTP_ACCOUNT"], ConfigurationManager.AppSettings["SFTP_PWD"]);
                    //string[] str1 = System.IO.Path.GetDirectoryName(localfilename).ToString().Split('\\');
                 
                    //string dic = str1[str1.Length - 1];
                    //LogUtil.Info("dic:{0}", dic);
                    //string localfilepath = System.IO.Path.GetDirectoryName(localfilename);
                    //if (!_ftpweb.DirectoryExist(dic))
                    //    _ftpweb.MakeDir(dic);
                    //_ftpweb.ftpURI = _ftpweb.ftpURI + "/" + dic + "/";
                    //LogUtil.Info("ftpURI:{0}", _ftpweb.ftpURI);
                    //if (!_ftpweb.DirectoryExist("Contract" + localfilepath.Replace(HETONGPATH_NEW, ""))) 
                    //    _ftpweb.MakeDir("Contract" + "\\" + localfilepath.Replace(HETONGPATH_NEW, ""));
                    //////_result = _BusinessLogsticBase.sftp_upload(localfilename, new string[] { filename }, rootPath + "\\" + localfilepath.Replace(HETONGPATH_NEW, ""), out msg);
                    //_ftpweb.ftpURI = _ftpweb.ftpURI + "Contract" + localfilepath.Replace(HETONGPATH_NEW, "");

                    //_ftpweb.Upload(localfilename);
                    //if (_result)
                    //{

                    //}
                    //else
                    //{
                    //    msg = "文件上传至一网通办异常";
                    //}
                }
                
                catch(Exception ex)
                {
                    LogUtil.Info("WTB上传合同失败...{0}", ex.Message);
                }
                }
            }
            #endregion
            return _result;
        }

        public bool UploadHeTong_XBQF(ref bool _result, string localfilename, string incident_id, string apply_no)
        {
            #region 上传到CSMSFTP
            if (_result)
            {
                LogUtil.Info("新表启封 本地合同创建成功...{0}", localfilename);
                //获取上级文件夹
                string[] str1 = System.IO.Path.GetDirectoryName(localfilename).ToString().Split('\\');
                string dic = str1[str1.Length - 1];

                _result = _BusinessLogsticBase.UploadFile2CSMS(dic, localfilename);
                if (_result)
                {
                    string _CSMS_PATH = ConfigurationManager.AppSettings["CSMS_PATH"];
                    string wenjianlj = "//" + _CSMS_PATH + "/" + dic + "/" + System.IO.Path.GetFileName(localfilename);
                    DataSet ds = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "INSERT;WTB_UPLOADHETONG;" + incident_id + ";" + wenjianlj, "");
                    if (ds.Tables[0].Rows[0]["MSGCODE"].ToString() == "00|")
                    {
                        _result = true;
                    }
                    else
                    {
                        LogUtil.Info("新表启封 CSMS上传合同成功...{0}..{1}", "文件上传至CSMS异常", _result);
                        _result = true;
                    }
                }
            }
            #endregion
            LogUtil.Info("新表启封 CSMS上传合同成功...{0}..{1}", localfilename, _result);
            #region 上传到网通办FTP
            string _AUTOUPLOAD = ConfigurationManager.AppSettings["AUTOUPLOAD"];
            if (_AUTOUPLOAD == "TRUE")
            {
                string Environment = ConfigurationManager.AppSettings["Environment"];
                if (Environment == "TEST")
                {
                    string[] str1 = System.IO.Path.GetDirectoryName(localfilename).ToString().Split('\\');
                    string dic = str1[str1.Length - 1];

                    var sftpPath = ConfigurationManager.AppSettings["SFTP_PATH"];
                    FtpWeb _ftpweb = new FtpWeb(ConfigurationManager.AppSettings["FTP_IP"], "", ConfigurationManager.AppSettings["FTP_ACCOUNT"], ConfigurationManager.AppSettings["FTP_PWD"]);

                    _ftpweb.ftpURI = _ftpweb.ftpURI + sftpPath + "/" + dic + "/";

                    string filenameUpload = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(localfilename) , apply_no + System.IO.Path.GetExtension(localfilename));
                    File.Copy(localfilename, filenameUpload, true);
                    _ftpweb.Upload(filenameUpload);
                }
                else
                {
                    try
                    {
                        string[] str1 = System.IO.Path.GetDirectoryName(localfilename).ToString().Split('\\');
                        string dic = str1[str1.Length - 1];

                        FtpWeb _ftpweb = new FtpWeb(ConfigurationManager.AppSettings["SFTP_IP"] + ":" + ConfigurationManager.AppSettings["SFTP_PORT"], ConfigurationManager.AppSettings["SFTP_PATH"], ConfigurationManager.AppSettings["SFTP_ACCOUNT"], ConfigurationManager.AppSettings["SFTP_PWD"]);
                        _ftpweb.SFTPOperation(ConfigurationManager.AppSettings["SFTP_IP"], "16022", ConfigurationManager.AppSettings["SFTP_ACCOUNT"], ConfigurationManager.AppSettings["SFTP_PWD"]);

                        LogUtil.Info("新表启封 WTB上传合同路径...{0}", ConfigurationManager.AppSettings["SFTP_IP"] + "|" + ConfigurationManager.AppSettings["SFTP_ACCOUNT"] + "|" + ConfigurationManager.AppSettings["SFTP_PWD"]);
                        LogUtil.Info("ftpURI:{0}", _ftpweb.ftpURI);
                        try
                        {
                            string filenameUpload = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(localfilename), apply_no + System.IO.Path.GetExtension(localfilename));
                            File.Copy(localfilename, filenameUpload, true);
                            _ftpweb.Put(filenameUpload, ConfigurationManager.AppSettings["SFTP_PATH"] + "/" + str1[str1.Length - 1].ToString(), System.IO.Path.GetFileName(filenameUpload));
                        }
                        catch (Exception ex)
                        {
                            LogUtil.Info("新表启封 ftpURIException:{0}", ex.Message);
                        }
        
                    }

                    catch (Exception ex)
                    {
                        LogUtil.Info("新表启封 WTB上传合同失败...{0}", ex.Message);
                    }
                }
            }
            #endregion
            return _result;
        }

        private void CreateDirectory(string remotePath)
        {

            FtpWeb ftp = new FtpWeb(ConfigurationManager.AppSettings["FTP_IP"], "", ConfigurationManager.AppSettings["FTP_ACCOUNT"], ConfigurationManager.AppSettings["FTP_PWD"]);
            
            string[] paths = remotePath.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
            LogUtil.Info("目录全文件夹：" + remotePath +"|"+paths.Length.ToString());
            string curPath = "";
            for (int i = 0; i < paths.Length; i++)
            {
              try
              {
                curPath += paths[i];
                LogUtil.Info("创建目录文件夹：" + curPath + i);
                if (i!=0)
                {
                    LogUtil.Info("创建目录：" + i);
                    ftp.MakeDir(curPath);
                    curPath += "/";
                }
                else
                {
                    curPath += "/";
                }
                //if (i < paths.Length - 1)
                //{
                //    curPath += "/";
                //}
                
                LogUtil.Info("创建目录文件夹层级："+i);
               }
               catch(Exception ex)
               {
                   LogUtil.Info("创建目录文件夹失败：" + ex.Message);
                   continue;
               }
            }            
        }

        /// <summary>
        /// 一户多人口
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="S_IP"></param>
        // <returns></returns>
        public YHDRK_XiangYingEntity multiPopulation(multiPopulationEntity rpEntity, string S_IP)
        {
            #region 定义变量
            ///////int i_WsNo = (int)Web_Service_Name.WatermeterSplit;//接口名称在枚举中对应的编号
            string STR_CURRENT_COMPANY = ConfigurationManager.AppSettings["CURRENT_COMPANY"];
            int i_code = 0;
            bool b_isGood = true;
            string s_result = string.Empty;//记录操作结果
            string body = "";

            YHDRK_XiangYingEntity _XiangYingEntity = new YHDRK_XiangYingEntity();
            StringBuilder s_message = new StringBuilder();
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_YIHUDRKXX _outWTB_YIHUDRKXX = new WTB_YIHUDRKXX();

            #endregion

            try
            {
                #region 记录参数
                //s_message.Append(_BusinessLogsticBase.GetParameterByMethod(i_WsNo, rpEntity));
                body = JsonConvert.SerializeObject(rpEntity);
                LogUtil.Info("multiPopulation方法接收" + S_IP + "请求：" + body);
                #endregion

                #region 验证参数
                string[] req_type={"01","02","03","04"};
                string[] settle_method = { "01","02"};
                string[] include_applicant={ "01","02"};
                //不能为空
                if (string.IsNullOrEmpty(rpEntity.incident_id)) { i_code = 11; s_result = "申请单唯一ID" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.apply_no)) { i_code = 11; s_result = "统一审批编码" + s_suffix_notEmpty; goto last; }
                
                if (string.IsNullOrEmpty(rpEntity.applicant)) { i_code = 11; s_result = "申请人姓名" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.appdate)) { i_code = 11; s_result = "申请时间" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.cert_type)) { i_code = 11; s_result = "申请人证件类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.cert_number)) { i_code = 11; s_result = "申请人证件号码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.contact_num)) { i_code = 11; s_result = "联系人电话" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.req_type)) { i_code = 11; s_result = "办理类型" + s_suffix_notEmpty; goto last; }
                if (!string.IsNullOrEmpty(rpEntity.req_type) && !req_type.Contains(rpEntity.req_type)) { i_code = 43; s_result = "办理类型值不正确"; goto last; }
                if (string.IsNullOrEmpty(rpEntity.company)) { i_code = 11; s_result = "水务公司" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.card_id)) { i_code = 11; s_result = "销根号" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.settle_method)) { i_code = 11; s_result = "优惠方式" + s_suffix_notEmpty; goto last; }

                if (_BusinessLogsticBase.selectList(rpEntity.CertList, "02", "01").Count < 5) { i_code = 41; s_result = "受益人少于5，不符合一户多人口条件"; goto last; }
                if (rpEntity.settle_method == "02" && Convert.ToInt32(_BusinessLogsticBase.selectList(rpEntity.CertList, "02", "01").Count) < 7) { i_code = 42; s_result = "优惠方式与受益人数不符"; goto last; }

                List<CertList> list = _BusinessLogsticBase.selectList(rpEntity.CertList, "02", "01");//是受益人且证明信息=身份证明
                int PEOPLE_NUM = _BusinessLogsticBase.getPEOPLE_NUM(list);
                //LogUtil.Info("申请单ID：{0},受益人数:{1}",rpEntity.incident_id, PEOPLE_NUM);
                if (PEOPLE_NUM < 5) { i_code = 41; s_result = "受益人少于5，不符合一户多人口条件"; goto last; }
                if (rpEntity.settle_method == "02" && PEOPLE_NUM < 7) { i_code = 42; s_result = "优惠方式与受益人数不符"; goto last; }


                if (!string.IsNullOrEmpty(rpEntity.settle_method)&&!settle_method.Contains(rpEntity.settle_method)) { i_code = 44; s_result = "优惠方式不存在"; goto last; }
                if (string.IsNullOrEmpty(rpEntity.ywyhdz)) { i_code = 11; s_result = "业务优惠地址" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.address)) { i_code = 11; s_result = "用水地址" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.address_check)) { i_code = 11; s_result = "地址校验结果" + s_suffix_notEmpty; goto last; }//
                if (string.IsNullOrEmpty(rpEntity.oper_type)) { i_code = 11; s_result = "办件类型" + s_suffix_notEmpty; goto last; }

                
                //验证列表
                if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                {
                    b_isGood = new BusinessLogsticBase().ValidateCertList(rpEntity.CertList,"01", out s_result);
                    if (!b_isGood) { i_code = 11; goto last; }
                }
                #endregion

                #region 验证该INCIDENT_ID记录是否已存在
                b_isGood = _BusinessLogsticBase.IsIncident_IDExist(rpEntity.incident_id);
                if (!b_isGood)
                {
                    i_code = 9;
                    s_result = string.Format("申请单号:{0}已存在", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0}已存在", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetYHDRK_XiangYingResult(rpEntity.card_id, "25", rpEntity.incident_id, rpEntity.apply_no, i_code, s_result);
                    goto last;
                }

                b_isGood = _BusinessLogsticBase.IsApply_no_Exist(rpEntity.apply_no);
                if (!b_isGood)
                {
                    i_code = 16;
                    s_result = string.Format("统一审批编码:{0}已存在", rpEntity.apply_no);
                    s_message.AppendFormat("统一审批编码:{0}已存在", rpEntity.apply_no);
                    _XiangYingEntity = _BusinessLogsticBase.GetYHDRK_XiangYingResult(rpEntity.card_id, "25", rpEntity.incident_id, rpEntity.apply_no, i_code, s_result);
                    goto last;
                }
                #endregion


                _BusinessLogsticBase.CreatemultiPopulationEntity(rpEntity, out _outWTB_YEWUZB, out _outWTB_YIHUDRKXX);

                ResultEntity _result = searchWaterUserInfo(_outWTB_YEWUZB.CARD_ID, _outWTB_YEWUZB.BUSINESS_TYPE, "", "0");//再次调用业务校验接口

                
                b_isGood = _result.isSuccess;
                if (!b_isGood)
                {
                    i_code = Convert.ToInt32(_result.errCode);
                    s_result = string.Format("申请单号:{0} 校验未通过 {1}", rpEntity.incident_id, _result.message);
                    s_message.AppendFormat("申请单号:{0}  网通办校验未通过", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetYHDRK_XiangYingResult(rpEntity.card_id, "25", rpEntity.incident_id, rpEntity.apply_no, i_code, s_result);
                    goto last;
                }

                //获取表卡当前信息
                string strCS = (_outWTB_YIHUDRKXX.SETTLE_METHOD == "01" ? "L" : "J") + "|" + _outWTB_YIHUDRKXX.REQ_TYPE + "";
                _result = _BusinessLogsticBase.VALIDATEYEWU(_outWTB_YEWUZB.CARD_ID, _outWTB_YEWUZB.BUSINESS_TYPE, strCS);
                b_isGood = _result.isSuccess;
                if (!b_isGood)
                {
                    i_code = Convert.ToInt32(_result.errCode);
                    s_result = string.Format("申请单号:{0} 校验未通过 {1}", rpEntity.incident_id, _result.message);
                    s_message.AppendFormat("申请单号:{0}  网通办校验未通过", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetYHDRK_XiangYingResult(rpEntity.card_id, "25", rpEntity.incident_id, rpEntity.apply_no, i_code, s_result);
                    goto last;
                }

                #region 写入数据库
                //写入数据库主表
                b_isGood = _BusinessLogsticBase.IsMainInsGoodByID(_outWTB_YEWUZB);
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetYHDRK_XiangYingResult(rpEntity.card_id, "25", rpEntity.incident_id, rpEntity.apply_no, i_code, s_result);
                    goto last;
                }
                //写入子表
                b_isGood = _BusinessLogsticBase.IsChildInsGoodByResult(_outWTB_YIHUDRKXX, "25");////需修改成string 类型
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} 网通办一户多人口子表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetYHDRK_XiangYingResult(rpEntity.card_id, "25", rpEntity.incident_id, rpEntity.apply_no, i_code, s_result);
                    goto last;
                }
                //写入证件列表
                if (b_isGood)
                {
                    if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                    {
                        b_isGood = _BusinessLogsticBase.IsInsertCertListGood(rpEntity.CertList, _outWTB_YEWUZB);

                        if (!b_isGood)
                        {
                            i_code = 12;
                            s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 证件列表数和成功写入WTB_WENJIANXX表记录数不符", rpEntity.incident_id);
                            _XiangYingEntity = _BusinessLogsticBase.GetYHDRK_XiangYingResult(rpEntity.card_id, "25", rpEntity.incident_id, rpEntity.apply_no, i_code, s_result);
                            goto last;
                        }
                        else
                        {
                            i_code = 200;
                            s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                            if (STR_CURRENT_COMPANY == "PDWLY" || STR_CURRENT_COMPANY == "TRUE")//判断是否自动启流程
                            {
                                /*
                                V_incident_id ,
                                V_LEIXING       ,---01-新办；02-续办；03-中止;04 -变更
                                V_CID           ,
                                V_FANGAN       ,--L 加量；J	加价
                                V_RENKOUS       ,
                                V_CAOZUOR       ,
                                 */
                                strCS="";
                                strCS+=rpEntity.incident_id+";";//V_incident_id
                                strCS += _outWTB_YIHUDRKXX.REQ_TYPE + ";";//V_LEIXING
                                strCS += _outWTB_YEWUZB.CARD_ID + ";";//V_CID
                                strCS += (_outWTB_YIHUDRKXX.SETTLE_METHOD == "01" ? "L" : "J") + ";";//V_FANGAN
                                strCS += _outWTB_YIHUDRKXX.PEOPLE_NUM + ";";//V_RENKOUS
                                strCS += "一网通办" + "";//V_CAOZUOR

                                LogUtil.Info("WTB_DUORENKFF 处理{0}",strCS);
                                DataTable dt_bgxx = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "UPDATE;WTB_DUORENKFF;"+strCS, "").Tables[0]; //_AccessDataBase.WTB_DUORENKFF("1", rpEntity.card_id, kehulx, zhengjianlx, rpEntity.id_nbr, rpEntity.entity_name, "", rpEntity.applicant, dianhua, shouji, "一网通办", rpEntity.incident_id, null);
                                if (dt_bgxx.Rows[0][0].ToString() != "00|")
                                {
                                    i_code = 12;
                                    s_message.Clear();
                                    s_message.AppendFormat("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                                    s_result = string.Format("申请单号:{0} 办理失败", rpEntity.incident_id);
                                    _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                                    _XiangYingEntity = _BusinessLogsticBase.GetYHDRK_XiangYingResult(rpEntity.card_id, "25", rpEntity.incident_id, rpEntity.apply_no, i_code, s_result);
                                    goto last;
                                }
                            }
                        }
                    }
                    else
                    {
                        i_code = 200;
                        s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                        s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                i_code = 12;
                s_result = string.Format("申请单号：{0} 操作出现异常", rpEntity.incident_id);
                s_message.AppendFormat("申请单号：{0}操作失败,错误：{1}", rpEntity.incident_id, ex.Message);
                _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                _XiangYingEntity = _BusinessLogsticBase.GetYHDRK_XiangYingResult(rpEntity.card_id, "25", rpEntity.incident_id, rpEntity.apply_no, i_code, s_result);
                goto last;
            }
            finally
            {
                //记日志
                LogUtil.Info(s_message.ToString());
            }
        last:
            _XiangYingEntity = _BusinessLogsticBase.GetYHDRK_XiangYingResult(rpEntity.card_id, "25", rpEntity.incident_id, rpEntity.apply_no, i_code, s_result);
            _XiangYingEntity.incident_id = rpEntity.incident_id;
            body = JsonConvert.SerializeObject(_XiangYingEntity);
            LogUtil.Info("multiPopulation方法返回" + S_IP + "结果：" + body);
            return _XiangYingEntity;
        }

        public YHDRK_XiangYingEntity uniTransfer(uniTransferEntity rpEntity, string S_IP)
        {

            #region 定义变量
            string STR_CURRENT_COMPANY = ConfigurationManager.AppSettings["CURRENT_COMPANY"];
            int i_code = 0;
            bool b_isGood = true;
            string s_incident_type = "26";//此处为incident_type
            string s_result = string.Empty;//记录操作结果
            string body = "";
            StringBuilder s_message = new StringBuilder();
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_GUOHUXX _outWTB_GUOHUXX = new WTB_GUOHUXX();
            YHDRK_XiangYingEntity _XiangYingEntity = new YHDRK_XiangYingEntity();
            #endregion

            try
            {
                #region 记录参数
                //s_message.Append(_BusinessLogsticBase.GetParameterByMethod(i_WsNo, rpEntity));
                body = JsonConvert.SerializeObject(rpEntity);
                LogUtil.Info("uniTransfer方法接收" + S_IP + "请求：" + body);
                #endregion

                #region 验证参数
                //不能为空
                if (string.IsNullOrEmpty(rpEntity.incident_id)) { i_code = 11; s_result = "申请单唯一ID" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.apply_no)) { i_code = 11; s_result = "统一审批编码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.applicant)) { i_code = 11; s_result = "申请人" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.appdate)) { i_code = 11; s_result = "申请时间" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.cert_type)) { i_code = 11; s_result = "申请人证件类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.cert_number)) { i_code = 11; s_result = "申请人证件号码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.card_id)) { i_code = 11; s_result = "销根号" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.fczjlx)) { i_code = 11; s_result = "房产证件类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.fczjhm)) { i_code = 11; s_result = "房产证件号码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.address)) { i_code = 11; s_result = "用水地址" + s_suffix_notEmpty; goto last; }
                //if (string.IsNullOrEmpty(rpEntity.bdczl)) { i_code = 11; s_result = "不动产坐落" + s_suffix_notEmpty; goto last; }

                //if (string.IsNullOrEmpty(rpEntity.passdate)) { i_code = 11; s_result = "不动产坐落登薄日期" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.contact_num)) { i_code = 11; s_result = "联系人电话" + s_suffix_notEmpty; goto last; }
                
                //验证列表
                if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                {
                    b_isGood = new BusinessLogsticBase().ValidateCertList(rpEntity.CertList, out s_result);
                    if (!b_isGood) { i_code = 11; goto last; }
                }

                #endregion

                #region 验证该INCIDENT_ID记录是否已存在
                b_isGood = _BusinessLogsticBase.IsIncident_IDExist(rpEntity.incident_id);
                if (!b_isGood)
                {
                    i_code = 9;
                    s_result = string.Format("申请单号:{0}已存在", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0}已存在", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetYHDRK_XiangYingResult(rpEntity.card_id, "26", rpEntity.incident_id, rpEntity.apply_no, i_code, s_result);
                    goto last;
                }
                #endregion

                #region 验证该apply_no记录是否已存在
                b_isGood = _BusinessLogsticBase.IsApply_no_Exist(rpEntity.apply_no);
                if (!b_isGood)
                {
                    i_code = 16;
                    s_result = string.Format("统一审批编码:{0}已存在", rpEntity.apply_no);
                    s_message.AppendFormat("统一审批编码:{0}已存在", rpEntity.apply_no);
                    _XiangYingEntity = _BusinessLogsticBase.GetYHDRK_XiangYingResult(rpEntity.card_id, "26", rpEntity.incident_id, rpEntity.apply_no, i_code, s_result);
                    goto last;
                }
                #endregion
                #region 验证该apply_no记录是否已存在
                b_isGood = _BusinessLogsticBase.IsApply_no_Exist(rpEntity.apply_no);
                if (!b_isGood)
                {
                    i_code = 16;
                    s_result = string.Format("统一审批编码:{0}已存在", rpEntity.apply_no);
                    s_message.AppendFormat("统一审批编码:{0}已存在", rpEntity.apply_no);
                    _XiangYingEntity = _BusinessLogsticBase.GetYHDRK_XiangYingResult(rpEntity.card_id, "26", rpEntity.incident_id, rpEntity.apply_no, i_code, s_result);
                    goto last;
                }
                #endregion
                _BusinessLogsticBase.CreateuniTransferEntity(rpEntity, out _outWTB_YEWUZB, out _outWTB_GUOHUXX);
                ResultEntity _result = _BusinessLogsticBase.VALIDATEYEWU(_outWTB_YEWUZB.CARD_ID, _outWTB_YEWUZB.BUSINESS_TYPE, rpEntity.fczjhm);
                b_isGood = _result.isSuccess;
                if (!b_isGood)
                {
                    i_code = Convert.ToInt32(_result.errCode);
                    s_result = string.Format(" 校验未通过 {1}", rpEntity.incident_id, _result.message);
                    s_message.AppendFormat(" 一网通办校验未通过", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetYHDRK_XiangYingResult(rpEntity.card_id, "26", rpEntity.incident_id, rpEntity.apply_no, i_code, s_result);
                    goto last;
                }
                _result = searchWaterUserInfo(_outWTB_YEWUZB.CARD_ID, _outWTB_YEWUZB.BUSINESS_TYPE, "", "0");//再次调用业务校验接口
                b_isGood = _result.isSuccess;
                if (!b_isGood)
                {
                    i_code = Convert.ToInt32(_result.errCode);
                    s_result = string.Format("申请单号:{0} 操作出现异常 {1}", rpEntity.incident_id, _result.message);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetYHDRK_XiangYingResult(rpEntity.card_id, "26", rpEntity.incident_id, rpEntity.apply_no, i_code, s_result);
                    goto last;
                }

                #region 写入数据库
                //写入数据库主表
                b_isGood = _BusinessLogsticBase.IsMainInsGoodByID(_outWTB_YEWUZB);
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetYHDRK_XiangYingResult(rpEntity.card_id, "26", rpEntity.incident_id, rpEntity.apply_no, i_code, s_result);
                    goto last;
                }
                //写入子表
                b_isGood = _BusinessLogsticBase.IsChildInsGoodByResult(_outWTB_GUOHUXX, s_incident_type);////需修改成string 类型
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_GUOHUXX表新增失败", rpEntity.incident_id);
                    _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                    _XiangYingEntity = _BusinessLogsticBase.GetYHDRK_XiangYingResult(rpEntity.card_id, "26", rpEntity.incident_id, rpEntity.apply_no, i_code, s_result);
                    goto last;
                }
                //写入证件列表
                if (b_isGood)
                {
                    if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                    {
                        
                        b_isGood = _BusinessLogsticBase.IsInsertCertListGood(rpEntity.CertList, _outWTB_YEWUZB);                        
                        if (!b_isGood)
                        {
                            i_code = 12;
                            s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 证件列表数和成功写入WTB_WENJIANXX表记录数不符", rpEntity.incident_id);
                            _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                            _XiangYingEntity = _BusinessLogsticBase.GetYHDRK_XiangYingResult(rpEntity.card_id, "26", rpEntity.incident_id, rpEntity.apply_no, i_code, s_result);
                            goto last;
                        }
                        else
                        {
                            i_code = 200;
                            s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                            if (STR_CURRENT_COMPANY == "PDWLY" || STR_CURRENT_COMPANY == "TRUE")//判断当前公司是否为威立雅
                            {
                                string kehulx =  "0";
                                string zhengjianmc = "";
                                string zhengjianlx = _BusinessLogsticBase.getZhengJianLX(rpEntity.cert_type, out zhengjianmc);
                                string dianhua =  "";
                                string shouji = rpEntity.contact_num ;
                                string s_hm = rpEntity.applicant;
                                DataTable dt_bgxx = _AccessDataBase.KEHUXXBG("0", rpEntity.card_id, kehulx, zhengjianlx, rpEntity.cert_number, s_hm, rpEntity.email, rpEntity.applicant, dianhua, shouji, "一网通办", rpEntity.incident_id, null);
                                if (dt_bgxx.Rows[0][0].ToString() != "00|")
                                {
                                    i_code = 12;
                                    s_message.Clear();
                                    s_message.AppendFormat("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                                    s_result = string.Format("申请单号:{0} 办理失败", rpEntity.incident_id);
                                    _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                                    _XiangYingEntity = _BusinessLogsticBase.GetYHDRK_XiangYingResult(rpEntity.card_id, "26", rpEntity.incident_id, rpEntity.apply_no, i_code, s_result);
                                    goto last;
                                }
                            }
                        }
                    }
                    else
                    {
                        i_code = 200;
                        s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                        s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                        if (STR_CURRENT_COMPANY == "PDWLY" || STR_CURRENT_COMPANY == "TRUE")//判断当前公司是否为威立雅
                        {
                            string kehulx =  "0" ;
                            string zhengjianmc = "";
                            string zhengjianlx = _BusinessLogsticBase.getZhengJianLX(rpEntity.cert_type, out zhengjianmc);
                            string dianhua =  "";
                            string shouji = rpEntity.contact_num;
                            string s_hm = rpEntity.applicant;
                            DataTable dt_bgxx = _AccessDataBase.KEHUXXBG("0", rpEntity.card_id, kehulx, zhengjianlx, rpEntity.cert_number, s_hm, rpEntity.email, rpEntity.applicant, dianhua, shouji, "一网通办", rpEntity.incident_id, null);
                            if (dt_bgxx.Rows[0][0].ToString() != "00|")
                            {
                                i_code = 12;
                                s_message.Clear();
                                s_message.AppendFormat("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                                s_result = string.Format("申请单号:{0} 办理失败", rpEntity.incident_id);
                                _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                                _XiangYingEntity = _BusinessLogsticBase.GetYHDRK_XiangYingResult(rpEntity.card_id, "26", rpEntity.incident_id, rpEntity.apply_no, i_code, s_result);
                                goto last;
                            }
                        }
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                i_code = 12;
                s_result = string.Format("申请单号：{0} 操作出现异常", rpEntity.incident_id);
                s_message.AppendFormat("申请单号：{0}操作失败,错误：{1}", rpEntity.incident_id, ex.Message);
                _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                _XiangYingEntity = _BusinessLogsticBase.GetYHDRK_XiangYingResult(rpEntity.card_id, "26", rpEntity.incident_id, rpEntity.apply_no, i_code, s_result);
                goto last;
            }
            finally
            {
                //记日志
                LogUtil.Info(s_message.ToString());
            }
        last:
            _XiangYingEntity = _BusinessLogsticBase.GetYHDRK_XiangYingResult(rpEntity.card_id, "26", rpEntity.incident_id, rpEntity.apply_no, i_code, s_result);
            _XiangYingEntity.incident_id = rpEntity.incident_id;
            body = JsonConvert.SerializeObject(_XiangYingEntity);
            LogUtil.Info("uniTransfer方法返回" + S_IP + "结果：" + body);
            return _XiangYingEntity;
        }

        /// <summary>
        /// 客户联系信息变更
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="S_IP"></param>
        /// <returns></returns>
        public XiangYingEntity customerInfoChange(customerInfoChangeEntity rpEntity, string S_IP)
        {


            #region 定义变量
            string STR_CURRENT_COMPANY = ConfigurationManager.AppSettings["CURRENT_COMPANY"];
            int i_code = 0;
            bool b_isGood = true;
            string s_incident_type = rpEntity.business_type;//此处为incident_type
            string s_result = string.Empty;//记录操作结果
            string body = "";
            StringBuilder s_message = new StringBuilder();
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_KEHUXX _outWTB_KEHUXX = new WTB_KEHUXX();
            List<WTB_LIANXIXX> _outWTB_LIANXIXXs = new List<WTB_LIANXIXX>();
            XiangYingEntity _XiangYingEntity = new XiangYingEntity();
            #endregion

            try
            {
                #region 记录参数
                //s_message.Append(_BusinessLogsticBase.GetParameterByMethod(i_WsNo, rpEntity));
                body = JsonConvert.SerializeObject(rpEntity);
                LogUtil.Info("customerInfoChange方法接收" + S_IP + "请求：" + body);
                #endregion

                #region 验证参数
                //不能为空
                if (string.IsNullOrEmpty(rpEntity.incident_id)) { i_code = 11; s_result = "申请单唯一ID" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.apply_no)) { i_code = 11; s_result = "统一审批编码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.applicant)) { i_code = 11; s_result = "申请人" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.appdate)) { i_code = 11; s_result = "申请时间" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.business_type)) { i_code = 11; s_result = "业务类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.card_id)) { i_code = 11; s_result = "销根号" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.send_address)) { i_code = 11; s_result = "账单送达地址" + s_suffix_notEmpty; goto last; }
                if (rpEntity.conList.Count == 0) { i_code = 11; s_result = "联系人信息" + s_suffix_notEmpty; goto last; }

                foreach (var item in rpEntity.conList)
                {
                    if (string.IsNullOrEmpty(item.con_name)) { i_code = 11; s_result = "联系人姓名" + s_suffix_notEmpty; goto last; }
                    if (string.IsNullOrEmpty(item.con_value)) { i_code = 11; s_result = "联系电话" + s_suffix_notEmpty; goto last; }
                }
                

                //验证列表
                if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                {
                    b_isGood = new BusinessLogsticBase().ValidateCertList(rpEntity.CertList, out s_result);
                    if (!b_isGood) { i_code = 11; goto last; }
                }

                #endregion

                #region 验证该INCIDENT_ID记录是否已存在
                b_isGood = _BusinessLogsticBase.IsIncident_IDExist(rpEntity.incident_id);
                if (!b_isGood)
                {
                    i_code = 9;
                    s_result = string.Format("申请单号:{0}已存在", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0}已存在", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                #endregion
                _BusinessLogsticBase.CreatecustomerInfoChangeEntity(rpEntity, out _outWTB_YEWUZB, out _outWTB_KEHUXX, out _outWTB_LIANXIXXs);

                ResultEntity _result = searchWaterUserInfo(_outWTB_YEWUZB.CARD_ID, _outWTB_YEWUZB.BUSINESS_TYPE, "", "0");//再次调用业务校验接口
                b_isGood = _result.isSuccess;
                if (!b_isGood)
                {
                    i_code = Convert.ToInt32(_result.errCode);
                    s_result = string.Format("申请单号:{0} 操作出现异常 {1}", rpEntity.incident_id, _result.message);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }

                #region 写入数据库
                //写入数据库主表
                b_isGood = _BusinessLogsticBase.IsMainInsGoodByID(_outWTB_YEWUZB);
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入子表
                b_isGood = _BusinessLogsticBase.IsChildInsGoodByResult(_outWTB_KEHUXX, s_incident_type, _outWTB_LIANXIXXs.ConvertAll(s => (object)s));
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_KEHUXX表新增失败", rpEntity.incident_id);
                    _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入证件列表
                if (b_isGood)
                {
                    if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                    {
                        b_isGood = _BusinessLogsticBase.IsInsertCertListGood(rpEntity.CertList, _outWTB_YEWUZB);
                        if (!b_isGood)
                        {
                            i_code = 12;
                            s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 证件列表数和成功写入WTB_WENJIANXX表记录数不符", rpEntity.incident_id);
                            _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            goto last;
                        }
                        else
                        {
                            i_code = 200;
                            s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                            if (STR_CURRENT_COMPANY == "PDWLY" || STR_CURRENT_COMPANY == "TRUE")//判断当前公司是否为威立雅
                            {
                                string kehulx = "0";
                                string zhengjianlx = "";
                                string dianhua = "";
                                string shouji = "";
                                string email = rpEntity.yb + "|" + rpEntity.receiver + "|" + rpEntity.send_address;
                                DataTable dt_bgxx = _AccessDataBase.KEHUXXBG("2", rpEntity.card_id, kehulx, zhengjianlx, "", "", email, rpEntity.applicant, dianhua, shouji, "一网通办", rpEntity.incident_id, null);
                                if (dt_bgxx.Rows[0][0].ToString() != "00|")
                                {
                                    i_code = 12;
                                    s_message.Clear();
                                    s_message.AppendFormat("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                                    s_result = string.Format("申请单号:{0} 办理失败", rpEntity.incident_id);
                                    _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                                    goto last;
                                }
                            }
                        }
                    }
                    else
                    {
                        i_code = 200;
                        s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                        s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                        if (STR_CURRENT_COMPANY == "PDWLY" || STR_CURRENT_COMPANY == "TRUE")//判断当前公司是否为威立雅
                        {
                            string kehulx = "0";
                            string zhengjianlx = "";
                            string dianhua = "";
                            string shouji = "";
                            string email = rpEntity.yb + "|" + rpEntity.receiver + "|" + rpEntity.send_address;
                            DataTable dt_bgxx = _AccessDataBase.KEHUXXBG("2", rpEntity.card_id, kehulx, zhengjianlx, "", "", email, rpEntity.applicant, dianhua, shouji, "一网通办", rpEntity.incident_id, null);
                            if (dt_bgxx.Rows[0][0].ToString() != "00|")
                            {
                                i_code = 12;
                                s_message.Clear();
                                s_message.AppendFormat("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                                s_result = string.Format("申请单号:{0} 办理失败", rpEntity.incident_id);
                                _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                                _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                                goto last;
                            }
                        }
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                i_code = 12;
                s_result = string.Format("申请单号：{0} 操作出现异常", rpEntity.incident_id);
                s_message.AppendFormat("申请单号：{0}操作失败,错误：{1}", rpEntity.incident_id, ex.Message);
                _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                goto last;
            }
            finally
            {
                //记日志
                LogUtil.Info(s_message.ToString());
            }
        last:
            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
            _XiangYingEntity.incident_id = rpEntity.incident_id;
            body = JsonConvert.SerializeObject(_XiangYingEntity);
            LogUtil.Info("customerInfoChange方法返回" + S_IP + "结果：" + body);
            return _XiangYingEntity;
        }

        /// <summary>
        /// 5.12	补寄账单前置查询接口
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="S_IP"></param>
        /// <returns></returns>
        public queryBillResultEntity queryBill(queryBillEntity rpEntity, string S_IP)
        {
            queryBillResultEntity _queryBillResultEntity = new queryBillResultEntity();//业务校验结果entity
            string body = "";
            _queryBillResultEntity.card_id = rpEntity.card_id;
            _queryBillResultEntity.isSuccess = true;
            _queryBillResultEntity.code = 200;//HTTP状态码
            body = JsonConvert.SerializeObject(rpEntity);
            LogUtil.Info("queryBill方法接收" + S_IP + "请求：" + body);
            try
            {
                DataSet ds = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "SELECT;WTB_RESENDZDXX_SEARCH;" + rpEntity.card_id + ";", "");//_AccessDataBase.queryBill(card_id, businessType, queryType, null);
                
                    if (ds.Tables[0].Rows[0]["ErrorInfo"].ToString().Split('|')[0] == "00")
                    {
                        _queryBillResultEntity.isSuccess = true;
                        _queryBillResultEntity.code = 200;//HTTP状态码 
                        List<billList> _billList = new List<billList>();
                        foreach (DataRow dr in ds.Tables[1].Rows)
                        {
                            billList _bill = new billList();
                            _bill.bill_month = dr["bill_month"].ToString();
                            _bill.money = dr["money"].ToString();
                            _bill.pay_status = dr["pay_status"].ToString();
                            _billList.Add(_bill);
                        }
                        _queryBillResultEntity.billList = _billList;
                        goto last;
                    }
                    else
                    {
                        _queryBillResultEntity.isSuccess = false;
                        _queryBillResultEntity.code = 500;
                        _queryBillResultEntity.errCode = ds.Tables[0].Rows[0]["ErrorInfo"].ToString().Split('|')[0];
                        _queryBillResultEntity.message = ds.Tables[0].Rows[0]["ErrorInfo"].ToString().Split('|')[1];
                        goto last;
                    }
               
            }
            catch (Exception ex)
            {
                _queryBillResultEntity.code = 500;
                _queryBillResultEntity.errCode = "13";
                _queryBillResultEntity.message = "数据库连接失败";
                LogUtil.Info(ex.Message.ToString());
                goto last;
            }
            finally
            {
                //记日志
                string s_message = _queryBillResultEntity.message;
            }
        last:
            body = JsonConvert.SerializeObject(_queryBillResultEntity);
            LogUtil.Info("queryBill方法返回" + S_IP + "结果：" + body);
            return _queryBillResultEntity;
        }

        /// <summary>
        /// 5.13	补缴费通知单
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="S_IP"></param>
        /// <returns></returns>
        public XiangYingEntity payNoticeRemail(payNoticeRemailEntity rpEntity, string S_IP)
        {
            #region 定义变量
            string STR_CURRENT_COMPANY = ConfigurationManager.AppSettings["CURRENT_COMPANY"];
            int i_code = 0;
            bool b_isGood = true;
            string s_incident_type = rpEntity.business_type;//此处为incident_type
            string s_result = string.Empty;//记录操作结果
            string body = "";
            StringBuilder s_message = new StringBuilder();
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_FAPIAOXX _outWTB_FAPIAOXX = new WTB_FAPIAOXX();
            XiangYingEntity _XiangYingEntity = new XiangYingEntity();
            List<WTB_FAPIAOXX> _outWTB_BILLs = new List<WTB_FAPIAOXX>();
            #endregion

            try
            {
                #region 记录参数
                //s_message.Append(_BusinessLogsticBase.GetParameterByMethod(i_WsNo, rpEntity));
                body = JsonConvert.SerializeObject(rpEntity);
                LogUtil.Info("payNoticeRemail方法接收" + S_IP + "请求：" + body);
                #endregion

                #region 验证参数
                //不能为空
                if (string.IsNullOrEmpty(rpEntity.incident_id)) { i_code = 11; s_result = "申请单唯一ID" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.apply_no)) { i_code = 11; s_result = "统一审批编码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.applicant)) { i_code = 11; s_result = "申请人" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.contact_number)) { i_code = 11; s_result = "申请人联系方式" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.appdate)) { i_code = 11; s_result = "申请时间" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.business_type)) { i_code = 11; s_result = "业务类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.card_id)) { i_code = 11; s_result = "销根号" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.notice_type)) { i_code = 11; s_result = "缴费通知单类型" + s_suffix_notEmpty; goto last; }

                
                //验证列表
                if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                {
                    b_isGood = new BusinessLogsticBase().ValidateCertList(rpEntity.CertList, out s_result);
                    if (!b_isGood) { i_code = 11; goto last; }
                }

                #endregion

                #region 验证该INCIDENT_ID记录是否已存在
                b_isGood = _BusinessLogsticBase.IsIncident_IDExist(rpEntity.incident_id);
                if (!b_isGood)
                {
                    i_code = 9;
                    s_result = string.Format("申请单号:{0}已存在", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0}已存在", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                #endregion
                _BusinessLogsticBase.CreatepayNoticeRemailEntity(rpEntity, out _outWTB_YEWUZB, out _outWTB_BILLs);

                queryBillEntity _queryBillEntity = new queryBillEntity();
                _queryBillEntity.card_id = rpEntity.card_id;
                queryBillResultEntity _result = queryBill(_queryBillEntity,S_IP);//再次调用验接口
                b_isGood = _result.isSuccess;
                if (!b_isGood)
                {
                    i_code = Convert.ToInt32(_result.errCode);
                    s_result = string.Format("申请单号:{0} 操作出现异常 {1}", rpEntity.incident_id, _result.message);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }

                #region 写入数据库
                //写入数据库主表
                b_isGood = _BusinessLogsticBase.IsMainInsGoodByID(_outWTB_YEWUZB);
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入子表
                b_isGood = _BusinessLogsticBase.IsChildInsGoodByResult(null, s_incident_type, _outWTB_BILLs.ConvertAll(s => (object)s));
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_FAPIAOXX表新增失败", rpEntity.incident_id);
                    _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入证件列表
                if (b_isGood)
                {
                    if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                    {
                        b_isGood = _BusinessLogsticBase.IsInsertCertListGood(rpEntity.CertList, _outWTB_YEWUZB);
                        if (!b_isGood)
                        {
                            i_code = 12;
                            s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 证件列表数和成功写入WTB_WENJIANXX表记录数不符", rpEntity.incident_id);
                            _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            goto last;
                        }
                        else
                        {
                            i_code = 200;
                            s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                            if (STR_CURRENT_COMPANY == "PDWLY" || STR_CURRENT_COMPANY == "TRUE")//判断当前公司是否为威立雅
                            {
                                string strParms="";
                                strParms+=rpEntity.notice_type+";";//v_notice_type varchar2,
                                strParms+=rpEntity.card_id+";";//         v_cid varchar2,
                                strParms+=rpEntity.applicant+";";//         v_lianxir varchar2,
                                strParms+=""+";";//         v_lianxidh varchar2,
                                strParms+=rpEntity.contact_number+";";//         v_lianxisj varchar2,
                                strParms+="一网通办"+";";//         V_CAOZUOR varchar2,
                                strParms += rpEntity.incident_id + ";";//         v_incident_id varchar2,
                                strParms += rpEntity.apply_no + "";//         v_apply_no    varchar2,
                                DataTable dt_bgxx = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "INSERT;WTB_RESENDZDXX;" + strParms, "").Tables[0];//KEHUXXBG("2", rpEntity.card_id, kehulx, zhengjianlx, "", "", email, rpEntity.applicant, dianhua, shouji, "一网通办", rpEntity.incident_id, null);
                                if (dt_bgxx.Rows[0][0].ToString() != "00|")
                                {
                                    i_code = 12;
                                    //s_result = string.Format("申请单号:{0} 办理失败", rpEntity.incident_id);
                                    //s_message.AppendFormat("申请单号:{0} 办理失败", rpEntity.incident_id);
                                    s_message.Clear();
                                    s_message.AppendFormat("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                                    s_result = string.Format("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);

                                    _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                                    goto last;
                                }
                            }
                        }
                    }
                    else
                    {
                        i_code = 200;
                        s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                        s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                        if (STR_CURRENT_COMPANY == "PDWLY" || STR_CURRENT_COMPANY == "TRUE")//判断当前公司是否为威立雅
                        {
                            string strParms = "";
                            strParms += rpEntity.notice_type + ";";//v_notice_type varchar2,
                            strParms += rpEntity.card_id + ";";//         v_cid varchar2,
                            strParms += rpEntity.applicant + ";";//         v_lianxir varchar2,
                            strParms += "" + ";";//         v_lianxidh varchar2,
                            strParms += rpEntity.contact_number + ";";//         v_lianxisj varchar2,
                            strParms += "一网通办" + ";";//         V_CAOZUOR varchar2,
                            strParms += rpEntity.incident_id + ";";//         v_incident_id varchar2,
                            strParms += rpEntity.apply_no + "";//         v_apply_no    varchar2,
                            DataTable dt_bgxx = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "INSERT;WTB_RESENDZDXX;" + strParms, "").Tables[0];//KEHUXXBG("2", rpEntity.card_id, kehulx, zhengjianlx, "", "", email, rpEntity.applicant, dianhua, shouji, "一网通办", rpEntity.incident_id, null);
                            if (dt_bgxx.Rows[0][0].ToString() != "00|")
                            {
                                i_code = 12;
                                s_message.Clear();
                                s_message.AppendFormat("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                                s_result = string.Format("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                                _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                                _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                                goto last;
                            }
                        }
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                i_code = 12;
                s_result = string.Format("申请单号：{0} 操作出现异常", rpEntity.incident_id);
                s_message.AppendFormat("申请单号：{0}操作失败,错误：{1}", rpEntity.incident_id, ex.Message);
                _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                goto last;
            }
            finally
            {
                //记日志
                LogUtil.Info(s_message.ToString());
            }
        last:
            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
            _XiangYingEntity.incident_id = rpEntity.incident_id;
            body = JsonConvert.SerializeObject(_XiangYingEntity);
            LogUtil.Info("payNoticeRemail方法返回" + S_IP + "结果：" + body);
            return _XiangYingEntity;
        }

        /// <summary>
        /// 5.14	电子发票前置查询
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="S_IP"></param>
        /// <returns></returns>
        public queryInvoiceResultEntity queryInvoice(queryInvoiceEntity rpEntity, string S_IP)
        {
            queryInvoiceResultEntity _queryInvoiceResultEntity = new queryInvoiceResultEntity();//业务校验结果entity
            string body = "";
            _queryInvoiceResultEntity.card_id = rpEntity.card_id;
            _queryInvoiceResultEntity.isSuccess = true;
            _queryInvoiceResultEntity.code = 200;//HTTP状态码
            body = JsonConvert.SerializeObject(rpEntity);
            LogUtil.Info("queryInvoice方法接收" + S_IP + "请求：" + body);

            #region 验证参数
            //不能为空
            if (string.IsNullOrEmpty(rpEntity.card_id))
            {
                _queryInvoiceResultEntity.isSuccess = false;
                _queryInvoiceResultEntity.errCode = "07";
                _queryInvoiceResultEntity.message = "销根号或用户号不能为空";
                goto last;
            }
            if (string.IsNullOrEmpty(rpEntity.start_date))
            {
                _queryInvoiceResultEntity.isSuccess = false;
                _queryInvoiceResultEntity.errCode = "07";
                _queryInvoiceResultEntity.message = "起始年月不能为空";
                goto last;
            }
            if (string.IsNullOrEmpty(rpEntity.end_date))
            {
                _queryInvoiceResultEntity.isSuccess = false;
                _queryInvoiceResultEntity.errCode = "07";
                _queryInvoiceResultEntity.message = "结束年月不能为空";
                goto last;
            }

            if (!String.IsNullOrWhiteSpace(rpEntity.start_date))//开始日期、结束日期 格式校验
            {
                string msgstr = _BusinessLogsticBase.yearAndMonthPanDuan(rpEntity.start_date.Trim(), "start_date");
                if (msgstr != "00|")
                {
                    _queryInvoiceResultEntity.isSuccess = false;
                    _queryInvoiceResultEntity.errCode = msgstr.Split('|')[0];
                    _queryInvoiceResultEntity.message = msgstr.Split('|')[1];
                    goto last;
                }
            }
            if (!String.IsNullOrWhiteSpace(rpEntity.end_date))//账务年月、开始日期、结束日期 格式校验
            {
                string msgstr = _BusinessLogsticBase.yearAndMonthPanDuan(rpEntity.end_date.Trim(), "end_date");
                if (msgstr != "00|")
                {
                    _queryInvoiceResultEntity.isSuccess = false;
                    _queryInvoiceResultEntity.errCode = msgstr.Split('|')[0];
                    _queryInvoiceResultEntity.message = msgstr.Split('|')[1];
                    goto last;
                }
            }

            if (!String.IsNullOrWhiteSpace(rpEntity.start_date) && !String.IsNullOrWhiteSpace(rpEntity.end_date))
            {
                int start = Convert.ToInt32(rpEntity.start_date.Trim());
                int end = Convert.ToInt32(rpEntity.end_date.Trim());
                if (start > end)
                {
                    _queryInvoiceResultEntity.isSuccess = false;
                    _queryInvoiceResultEntity.errCode = "07";
                    _queryInvoiceResultEntity.message = "起始日期不能大于结束日期";
                    goto last;
                }
            }
            #endregion
            try
            {
                DataSet ds = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "SELECT;WTB_FAPIAOXX_SEARCH;" + rpEntity.card_id + ";" + rpEntity.start_date+";"+rpEntity.end_date, "");//_AccessDataBase.queryInvoice(card_id, businessType, queryType, null);

                if (ds.Tables[0].Rows[0]["ErrorInfo"].ToString().Split('|')[0] == "00")
                {

                    _queryInvoiceResultEntity.isSuccess = true;
                    _queryInvoiceResultEntity.code = 200;//HTTP状态码
                    _queryInvoiceResultEntity.elecInvoiceAutoPush = ds.Tables[0].Rows[0]["elecInvoiceAutoPush"].ToString();
                    _queryInvoiceResultEntity.contact_number = ds.Tables[0].Rows[0]["contact_number"].ToString();
                    _queryInvoiceResultEntity.email = ds.Tables[0].Rows[0]["email"].ToString();
                    _queryInvoiceResultEntity.nsrsbh = ds.Tables[0].Rows[0]["nsrsbh"].ToString();
                    _queryInvoiceResultEntity.fptt = ds.Tables[0].Rows[0]["fptt"].ToString();
                    _queryInvoiceResultEntity.contact_invoice = ds.Tables[0].Rows[0]["contact_invoice"].ToString();

                    List<billInfo> _billList = new List<billInfo>();
                    foreach (DataRow dr in ds.Tables[1].Rows)
                    {
                        billInfo _bill = new billInfo();
                        _bill.user_name = dr["user_name"].ToString();
                        _bill.shw_address = dr["shw_address"].ToString();
                        _bill.money = dr["money"].ToString();

                        _bill.bill_date = dr["bill_date"].ToString();
                        _bill.reserve1 = dr["reserve1"].ToString();
                        _bill.reserve2 = dr["reserve2"].ToString();
                        _bill.reserve3 = dr["reserve3"].ToString();


                        _billList.Add(_bill);
                    }
                    _queryInvoiceResultEntity.billInfo = _billList;
                    goto last;
                }
                else
                {
                    _queryInvoiceResultEntity.isSuccess = false;
                    _queryInvoiceResultEntity.code = 500;
                    _queryInvoiceResultEntity.errCode = ds.Tables[0].Rows[0]["ErrorInfo"].ToString().Split('|')[0];
                    _queryInvoiceResultEntity.message = ds.Tables[0].Rows[0]["ErrorInfo"].ToString().Split('|')[1];
                    goto last;
                }

            }
            catch (Exception ex)
            {
                _queryInvoiceResultEntity.code = 500;
                _queryInvoiceResultEntity.errCode = "13";
                _queryInvoiceResultEntity.message = "数据库连接失败";
                LogUtil.Info(ex.Message.ToString());
                goto last;
            }
            finally
            {
                //记日志
                string s_message = _queryInvoiceResultEntity.message;
            }
        last:
            body = JsonConvert.SerializeObject(_queryInvoiceResultEntity);
            LogUtil.Info("queryInvoice方法返回" + S_IP + "结果：" + body);
            return _queryInvoiceResultEntity;
        }

        /// <summary>
        /// 电子发票自动推送
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="S_IP"></param>
        /// <returns></returns>
        public XiangYingEntity elecInvoiceAutoPush(elecInvoiceAutoPushEntity rpEntity, string S_IP)
        {
            #region 定义变量
            string STR_CURRENT_COMPANY = ConfigurationManager.AppSettings["CURRENT_COMPANY"];
            int i_code = 0;
            bool b_isGood = true;
            string s_incident_type = rpEntity.business_type;//此处为incident_type
            string s_result = string.Empty;//记录操作结果
            string body = "";
            StringBuilder s_message = new StringBuilder();
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_FAPIAOXX _outWTB_FAPIAOXX = new WTB_FAPIAOXX();
            XiangYingEntity _XiangYingEntity = new XiangYingEntity();
            List<WTB_FAPIAOXX> _outWTB_BILLs = new List<WTB_FAPIAOXX>();
            #endregion

            try
            {
                #region 记录参数
                //s_message.Append(_BusinessLogsticBase.GetParameterByMethod(i_WsNo, rpEntity));
                body = JsonConvert.SerializeObject(rpEntity);
                LogUtil.Info("elecInvoiceAutoPush方法接收" + S_IP + "请求：" + body);
                #endregion

                #region 验证参数
                //不能为空
                if (string.IsNullOrEmpty(rpEntity.incident_id)) { i_code = 11; s_result = "申请单唯一ID" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.apply_no)) { i_code = 11; s_result = "统一审批编码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.applicant)) { i_code = 11; s_result = "申请人" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.appdate)) { i_code = 11; s_result = "申请时间" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.business_type)) { i_code = 11; s_result = "业务类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.card_id)) { i_code = 11; s_result = "销根号" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.address)) { i_code = 11; s_result = "用水地址" + s_suffix_notEmpty; goto last; }

                //if (string.IsNullOrEmpty(rpEntity.social_credit_code)) { i_code = 11; s_result = "纳税人识别号" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.contact_number)) { i_code = 11; s_result = "联系电话" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.email)) { i_code = 11; s_result = "邮箱" + s_suffix_notEmpty; goto last; }
                //if (string.IsNullOrEmpty(rpEntity.social_credit_code)) { i_code = 11; s_result = "用水地址" + s_suffix_notEmpty; goto last; }//contact_invoice
                //if (string.IsNullOrEmpty(rpEntity.address)) { i_code = 11; s_result = "用水地址" + s_suffix_notEmpty; goto last; }//social_credit_code
                //if (string.IsNullOrEmpty(rpEntity.contact_value)) { i_code = 11; s_result = "申请类型" + s_suffix_notEmpty; goto last; }//contact_value
                //if (string.IsNullOrEmpty(rpEntity.address)) { i_code = 11; s_result = "用水地址" + s_suffix_notEmpty; goto last; }//email
                if (string.IsNullOrEmpty(rpEntity.apply_type)) { i_code = 11; s_result = "申请类型" + s_suffix_notEmpty; goto last; }//apply_type


                //验证列表
                if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                {
                    b_isGood = new BusinessLogsticBase().ValidateCertList(rpEntity.CertList, out s_result);
                    if (!b_isGood) { i_code = 11; goto last; }
                }

                #endregion

                #region 验证该INCIDENT_ID记录是否已存在
                b_isGood = _BusinessLogsticBase.IsIncident_IDExist(rpEntity.incident_id);
                if (!b_isGood)
                {
                    i_code = 9;
                    s_result = string.Format("申请单号:{0}已存在", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0}已存在", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                #endregion
                _BusinessLogsticBase.CreateelecInvoiceAutoPushEntity(rpEntity, out _outWTB_YEWUZB, out _outWTB_FAPIAOXX);


                ResultEntity _result = searchWaterUserInfo(rpEntity.card_id, s_incident_type, S_IP, "0");//queryInvoice(_queryInvoiceEntity, S_IP);//再次调用验接口
                b_isGood = _result.isSuccess;
                if (!b_isGood)
                {
                    i_code = Convert.ToInt32(_result.errCode);
                    s_result = string.Format("申请单号:{0} 操作出现异常 {1}", rpEntity.incident_id, _result.message);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }

                #region 写入数据库
                //写入数据库主表
                b_isGood = _BusinessLogsticBase.IsMainInsGoodByID(_outWTB_YEWUZB);
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入子表
                b_isGood = _BusinessLogsticBase.IsChildInsGoodByResult(_outWTB_FAPIAOXX, s_incident_type);
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_FAPIAOXX表新增失败", rpEntity.incident_id);
                    _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入证件列表
                if (b_isGood)
                {
                    if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                    {
                        b_isGood = _BusinessLogsticBase.IsInsertCertListGood(rpEntity.CertList, _outWTB_YEWUZB);
                        if (!b_isGood)
                        {
                            i_code = 12;
                            s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 证件列表数和成功写入WTB_WENJIANXX表记录数不符", rpEntity.incident_id);
                            _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            goto last;
                        }
                        else
                        {
                            i_code = 200;
                            s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                            if (STR_CURRENT_COMPANY == "PDWLY" || STR_CURRENT_COMPANY == "TRUE")//判断当前公司是否为威立雅
                            {
                                string strParms = "";
                                
                                strParms += rpEntity.apply_type + ";";//V_apply_type        VARCHAR2,--1-申请；2-修改；3-取消
                                strParms += rpEntity.card_id + ";";//V_CID               VARCHAR2,
                                strParms += rpEntity.applicant + ";";//V_applicant         VARCHAR2,
                                strParms += rpEntity.address + ";";//V_address           VARCHAR2,
                                strParms += rpEntity.social_credit_code + ";";//V_NSRH            VARCHAR2,
                                strParms += rpEntity.contact_number + ";";//V_LIANXIDH          VARCHAR2,
                                strParms += rpEntity.email + ";";//V_EMAIL             VARCHAR2,
                                strParms += "一网通办" + ";";//V_CAOZUOR           VARCHAR2,
                                strParms += rpEntity.apply_no + ";";//V_YEWUBH            VARCHAR2,
                                strParms += rpEntity.incident_id + "";//v_incident_id         VARCHAR2,
                                DataTable dt_bgxx = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "INSERT;WTB_DZFAPIAOYHADD;" + strParms, "").Tables[0];//KEHUXXBG("2", rpEntity.card_id, kehulx, zhengjianlx, "", "", email, rpEntity.applicant, dianhua, shouji, "一网通办", rpEntity.incident_id, null);
                                if (dt_bgxx.Rows[0][0].ToString() != "00|")
                                {
                                    i_code = 12;
                                    s_message.Clear();
                                    s_message.AppendFormat("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                                    s_result = string.Format("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                                    _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                                    goto last;
                                }
                            }
                        }
                    }
                    else
                    {
                        i_code = 200;
                        s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                        s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                        if (STR_CURRENT_COMPANY == "PDWLY" || STR_CURRENT_COMPANY == "TRUE")//判断当前公司是否为威立雅
                        {
                            string strParms = "";
                            strParms += rpEntity.apply_type + ";";//V_apply_type        VARCHAR2,--1-申请；2-修改；3-取消
                            strParms += rpEntity.card_id + ";";//V_CID               VARCHAR2,
                            strParms += rpEntity.applicant + ";";//V_applicant         VARCHAR2,
                            strParms += rpEntity.address + ";";//V_address           VARCHAR2,
                            strParms += rpEntity.social_credit_code + ";";//V_NSRH            VARCHAR2,
                            strParms += rpEntity.contact_number + ";";//V_LIANXIDH          VARCHAR2,
                            strParms += rpEntity.email + ";";//V_EMAIL             VARCHAR2,
                            strParms += "一网通办" + ";";//V_CAOZUOR           VARCHAR2,
                            strParms += rpEntity.apply_no + ";";//V_YEWUBH            VARCHAR2,
                            strParms += rpEntity.incident_id + "";//v_incident_id         VARCHAR2,
                            DataTable dt_bgxx = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "INSERT;WTB_DZFAPIAOYHADD;" + strParms, "").Tables[0];//KEHUXXBG("2", rpEntity.card_id, kehulx, zhengjianlx, "", "", email, rpEntity.applicant, dianhua, shouji, "一网通办", rpEntity.incident_id, null);
                            if (dt_bgxx.Rows[0][0].ToString() != "00|")
                            {
                                i_code = 12;
                                s_message.Clear();
                                s_message.AppendFormat("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                                s_result = string.Format("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                                _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                                _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                                goto last;
                            }
                        }
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                i_code = 12;
                s_result = string.Format("申请单号：{0} 操作出现异常", rpEntity.incident_id);
                s_message.AppendFormat("申请单号：{0}操作失败,错误：{1}", rpEntity.incident_id, ex.Message);
                _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                goto last;
            }
            finally
            {
                //记日志
                LogUtil.Info(s_message.ToString());
            }
        last:
            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
            _XiangYingEntity.incident_id = rpEntity.incident_id;
            body = JsonConvert.SerializeObject(_XiangYingEntity);
            LogUtil.Info("elecInvoiceAutoPush方法返回" + S_IP + "结果：" + body);
            return _XiangYingEntity;
        }

        /// <summary>
        /// 5.16	电子发票单次获取
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="S_IP"></param>
        /// <returns></returns>
        public elecInvoiceObtainResultEntity elecInvoiceObtain(elecInvoiceObtainEntity rpEntity, string S_IP)
        {
            #region 定义变量
            string STR_CURRENT_COMPANY = ConfigurationManager.AppSettings["CURRENT_COMPANY"];
            int i_code = 0;
            bool b_isGood = true;
            string s_incident_type = rpEntity.business_type;//此处为incident_type
            string s_result = string.Empty;//记录操作结果
            string body = "";
            StringBuilder s_message = new StringBuilder();
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_FAPIAOXX _outWTB_FAPIAOXX = new WTB_FAPIAOXX();
            XiangYingEntity _XiangYingEntity = new XiangYingEntity();
            elecInvoiceObtainResultEntity _elecInvoiceObtainResultEntity = new elecInvoiceObtainResultEntity();
            List<billList> _billList = new List<billList>();
            List<WTB_FAPIAOXX> _outWTB_BILLs = new List<WTB_FAPIAOXX>();
            #endregion
            string message = "";
            try
            {
                #region 记录参数
                //s_message.Append(_BusinessLogsticBase.GetParameterByMethod(i_WsNo, rpEntity));
                body = JsonConvert.SerializeObject(rpEntity);
                LogUtil.Info("elecInvoiceObtain方法接收" + S_IP + "请求：" + body);
                #endregion

                #region 验证参数
                //不能为空
                if (string.IsNullOrEmpty(rpEntity.incident_id)) { i_code = 11; s_result = "申请单唯一ID" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.apply_no)) { i_code = 11; s_result = "统一审批编码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.applicant)) { i_code = 11; s_result = "申请人" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.appdate)) { i_code = 11; s_result = "申请时间" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.business_type)) { i_code = 11; s_result = "业务类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.card_id)) { i_code = 11; s_result = "销根号" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.user_name)) { i_code = 11; s_result = "户名" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.shw_address)) { i_code = 11; s_result = "用水地址" + s_suffix_notEmpty; goto last; }
                //if (string.IsNullOrEmpty(rpEntity.bill_month)) { i_code = 11; s_result = "账单年月" + s_suffix_notEmpty; goto last; }//bill_month

                //if (string.IsNullOrEmpty(rpEntity.money)) { i_code = 11; s_result = "账单金额" + s_suffix_notEmpty; goto last; }//money	账单金额
                //if (string.IsNullOrEmpty(rpEntity.post_address)) { i_code = 11; s_result = "注册地址" + s_suffix_notEmpty; goto last; }//post_address	注册地址
                //if (string.IsNullOrEmpty(rpEntity.contact_invoice)) { i_code = 11; s_result = "发票电话号码" + s_suffix_notEmpty; goto last; }//contact_invoice	发票电话号码
                //if (string.IsNullOrEmpty(rpEntity.company_name)) { i_code = 11; s_result = "企业名称" + s_suffix_notEmpty; goto last; }//company_name	企业名称
                if (string.IsNullOrEmpty(rpEntity.contact_number)) { i_code = 11; s_result = "联系电话" + s_suffix_notEmpty; goto last; }//contact_number	联系电话
                if (string.IsNullOrEmpty(rpEntity.email)) { i_code = 11; s_result = "邮箱" + s_suffix_notEmpty; goto last; }//email	邮箱
                //if (string.IsNullOrEmpty(rpEntity.nsrsbh)) { i_code = 11; s_result = "纳税人识别号" + s_suffix_notEmpty; goto last; }//nsrsbh	纳税人识别号
                if (string.IsNullOrEmpty(rpEntity.fptt)) { i_code = 11; s_result = "发票抬头" + s_suffix_notEmpty; goto last; }//fptt	发票抬头
                if (rpEntity.fptt != rpEntity.user_name) { i_code = 11; s_result = "户名与发票抬头不一致"; goto last; }
                //if (string.IsNullOrEmpty(rpEntity.open_bank)) { i_code = 11; s_result = "开户行" + s_suffix_notEmpty; goto last; }//open_bank	开户行
                //if (string.IsNullOrEmpty(rpEntity.bank_card_no)) { i_code = 11; s_result = "银行卡号" + s_suffix_notEmpty; goto last; }//bank_card_no	银行卡号

                //if (string.IsNullOrEmpty(rpEntity.address)) { i_code = 11; s_result = "用水地址" + s_suffix_notEmpty; goto last; }//social_credit_code
                //if (string.IsNullOrEmpty(rpEntity.contact_value)) { i_code = 11; s_result = "申请类型" + s_suffix_notEmpty; goto last; }//contact_value
                //if (string.IsNullOrEmpty(rpEntity.address)) { i_code = 11; s_result = "用水地址" + s_suffix_notEmpty; goto last; }//email

                if (rpEntity.billList.Count < 0) { i_code = 11; s_result = "账单列表" + s_suffix_notEmpty; goto last; }

                //验证列表
                if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                {
                    b_isGood = new BusinessLogsticBase().ValidateCertList(rpEntity.CertList, out s_result);
                    if (!b_isGood) { i_code = 11; goto last; }
                }

                #endregion

                #region 验证该INCIDENT_ID记录是否已存在
                b_isGood = _BusinessLogsticBase.IsIncident_IDExist(rpEntity.incident_id);
                if (!b_isGood)
                {
                    i_code = 9;
                    s_result = string.Format("申请单号:{0}已存在", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0}已存在", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                #endregion
                _BusinessLogsticBase.CreateelecInvoiceObtainEntity(rpEntity, out _outWTB_YEWUZB, out _outWTB_BILLs);


                ResultEntity _result = searchWaterUserInfo(rpEntity.card_id, s_incident_type, S_IP, "0");//queryInvoice(_queryInvoiceEntity, S_IP);//再次调用验接口
                b_isGood = _result.isSuccess;
                if (!b_isGood)
                {
                    i_code = Convert.ToInt32(_result.errCode);
                    s_result = string.Format("申请单号:{0} 操作出现异常 {1}", rpEntity.incident_id, _result.message);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }

                #region 写入数据库
                //写入数据库主表
                b_isGood = _BusinessLogsticBase.IsMainInsGoodByID(_outWTB_YEWUZB);
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入子表
                //b_isGood = _BusinessLogsticBase.IsChildInsGoodByResult(_outWTB_FAPIAOXX, s_incident_type);
                b_isGood = _BusinessLogsticBase.IsChildInsGoodByResult(null, s_incident_type, _outWTB_BILLs.ConvertAll(s => (object)s));
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_FAPIAOXX表新增失败", rpEntity.incident_id);
                    _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入证件列表
                if (b_isGood)
                {
                    i_code = 200;
                    s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                    if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                    {
                        b_isGood = _BusinessLogsticBase.IsInsertCertListGood(rpEntity.CertList, _outWTB_YEWUZB);
                        if (!b_isGood)
                        {
                            i_code = 12;
                            s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 证件列表数和成功写入WTB_WENJIANXX表记录数不符", rpEntity.incident_id);
                            _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            goto last;
                        }
                    }
                    if (STR_CURRENT_COMPANY == "PDWLY" || STR_CURRENT_COMPANY == "TRUE")//判断当前公司是否为威立雅
                    {

                        string strParms = "";

                        strParms += rpEntity.user_name + ";";//V_USERNAME          VARCHAR2,
                        strParms += rpEntity.card_id + ";";//V_CID               VARCHAR2,
                        strParms += rpEntity.shw_address + ";";//v_shw_address       VARCHAR2,
                        strParms += rpEntity.nsrsbh + ";";//V_nsrsbh            VARCHAR2,
                        strParms += "" + ";";//V_bill_month        VARCHAR2,
                        strParms += "" + ";";//V_money             NUMBER,
                        strParms += rpEntity.email + ";";//v_email             VARCHAR2,
                        strParms += rpEntity.contact_number + ";";//v_contact_number    VARCHAR2,
                        strParms += "一网通办" + ";";//V_CAOZUOR           VARCHAR2,
                        strParms += rpEntity.apply_no + ";";//V_YEWUBH            VARCHAR2,
                        strParms += rpEntity.incident_id + "";//v_incident_id         VARCHAR2,
                        DataSet ds = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "INSERT;WTB_DZFAPIAOZDADD;" + strParms, "");//KEHUXXBG("2", rpEntity.card_id, kehulx, zhengjianlx, "", "", email, rpEntity.applicant, dianhua, shouji, "一网通办", rpEntity.incident_id, null);
                        if (ds.Tables[0].Rows[0][0].ToString().Split('|')[0] != "00")
                        {
                            i_code = 12;
                            s_message.Clear();
                            s_message.AppendFormat("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, ds.Tables[0].Rows[0][0].ToString().Split('|')[1]);
                            s_result = string.Format("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, ds.Tables[0].Rows[0][0].ToString().Split('|')[1]);
                            _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            goto last;
                        }
                        message = "本次共开具" + ds.Tables[1].Rows.Count + "其中";
                        foreach (DataRow item in ds.Tables[1].Rows)
                        {
                            billList _bill = new billList();
                            _bill.bill_month = item["BILL_MONTH"].ToString();
                            _bill.money = item["MONEY"].ToString();
                            if (item["MSGCODE"].ToString() != "1|")
                            {
                                _bill.invoice_status = item["MSGCODE"].ToString().Split('|')[0];
                                _bill.invoice_comment = item["MSGCODE"].ToString().Split('|')[1];
                            }
                            else
                            {
                                
                                VatIvoService.VatIvoServiceClient vat = new VatIvoService.VatIvoServiceClient();

                                LogUtil.Info("开始请求" + vat.Endpoint.Address + "VatIvoService:{0},{1},{2},{3}", rpEntity.incident_id,rpEntity.card_id, _bill.bill_month, _bill.money);
                                b_isGood = vat.QueryXml(rpEntity.card_id, rpEntity.user_name, rpEntity.shw_address, Convert.ToInt32(_bill.bill_month.Substring(0, 4)),Convert.ToInt32(_bill.bill_month.Substring(4, 2)), Convert.ToDecimal(_bill.money), rpEntity.nsrsbh, rpEntity.contact_number, rpEntity.email, "一网通办", 1,out s_result);
                                
                                if (!b_isGood)
                                {
                                    _bill.invoice_status = "2";
                                    _bill.invoice_comment = s_result;
                                    message = message + "," + _bill.bill_month.ToString() + "开票失败";
                                }
                                else
                                {
                                    _bill.invoice_status = "1";//1 开票成功，2开票失败
                                    _bill.invoice_comment = "";
                                    message = message + "," + _bill.bill_month.ToString() + "开票成功";
                                }
                                LogUtil.Info("接收响应" + vat.Endpoint.Address + "VatIvoService:{0},{1},{2},{3},{4},{5}", rpEntity.incident_id, rpEntity.card_id, _bill.bill_month, _bill.money, _bill.invoice_status, _bill.invoice_comment);
                            }
                            _billList.Add(_bill);
                        }
                        _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    }

                }
                #endregion
            }
            catch (Exception ex)
            {
                i_code = 12;
                s_message.Clear();
                s_result = string.Format("申请单号：{0} 操作出现异常", rpEntity.incident_id);
                s_message.AppendFormat("申请单号：{0}操作失败,错误：{1}", rpEntity.incident_id, ex.Message);
                _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                goto last;
            }
            finally
            {
                //记日志
                LogUtil.Info(s_message.ToString());
            }
        last:
            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
            _XiangYingEntity.incident_id = rpEntity.incident_id;
            _elecInvoiceObtainResultEntity.incident_id = rpEntity.incident_id;
            _elecInvoiceObtainResultEntity.isSuccess = _XiangYingEntity.isSuccess;
            _elecInvoiceObtainResultEntity.code = _XiangYingEntity.code;
            _elecInvoiceObtainResultEntity.errCode = _XiangYingEntity.errCode;
            _elecInvoiceObtainResultEntity.message = _XiangYingEntity.message;
            _elecInvoiceObtainResultEntity.billList = _billList;
            body = JsonConvert.SerializeObject(_elecInvoiceObtainResultEntity);
            LogUtil.Info("elecInvoiceObtain方法返回" + S_IP + "结果：" + body);

            #region 自动回单
            Thread thd = new Thread(delegate() { AutoRerun(rpEntity, message); });
            thd.Start(); 
            //var abcObject = new
            //{
            //    incident_id = rpEntity.incident_id,
            //    shw_company = "PDXQZLS",
            //    oper_id = "PDXQZLS",
            //    status = "IncidentStatus.Finish",
            //    result = "01",
            //    description = ""
            //};
            //string serJson = JsonConvert.SerializeObject(abcObject);
            //string strMsg = this.updateIncidentStatus(rpEntity.business_type, serJson);
            #endregion

            return _elecInvoiceObtainResultEntity;
        }

        public void AutoRerun(elecInvoiceObtainEntity rpEntity,string message)
        {
            Thread.Sleep(1000 * 120);
            #region 自动回单
            var abcObject = new
            {
                incident_id = rpEntity.incident_id,
                shw_company = "PDXQZLS",//PDXQZLS PDXQZLS
                oper_id = "PDXQZLS",
                status = "IncidentStatus.Finish",
                result = "01",
                description = message
            };
            string serJson = JsonConvert.SerializeObject(abcObject);
            LogUtil.Info("elecInvoiceObtain自动回单" + serJson);
            string strMsg = this.updateIncidentStatus(rpEntity.business_type, serJson);
            #endregion
        }

        /// <summary>
        /// 业务预约时间获取
        /// </summary>
        /// <param name="business_type"></param>
        /// <param name="card_id"></param>
        /// <param name="S_IP"></param>
        /// <returns></returns>
        public bookAvailableResultEntity bookAvailable(string business_type, string card_id, string S_IP)
        {
            bookAvailableResultEntity _bookAvailableResult = new bookAvailableResultEntity();
            _bookAvailableResult.code = 200;
            string body = "";

            LogUtil.Info("getbookAvailable方法接收" + S_IP + "请求：card_id:{0},business_type:{1}", card_id, business_type);

            try
            {
                DataTable dt = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "SELECT;WTB_GETBOOKAVAILABLE;" + business_type + ";" + card_id + "", "").Tables[0];//getbookAvailable(card_id,business_type, null);
                _bookAvailableResult.isSuccess = false;
                List<string> _bookList = new List<string>();
                if (dt.Rows[0]["MSGCODE"].ToString()=="00|")
                {
                    _bookAvailableResult.isSuccess = true;
                    foreach (DataRow dr in dt.Rows)
                    {
                        _bookList.Add(dr["S_YUYUERQ"].ToString());
                    }
                    //_bookAvailableResult.bookList = _bookList;
                }
                else
                {
                    _bookAvailableResult.errCode = "01";
                    _bookAvailableResult.message = "销根号不存在";
                }
            }
            catch (Exception ex)
            {
                _bookAvailableResult.errCode = "13";
                _bookAvailableResult.code = 500;
                _bookAvailableResult.message = ex.Message;
                throw ex;
            }
            body = JsonConvert.SerializeObject(_bookAvailableResult);
            LogUtil.Info("getbookAvailable方法返回" + S_IP + "结果：" + body);
            return _bookAvailableResult;
        }

        /// <summary>
        /// 5.20	水司地址匹配
        /// </summary>
        /// <param name="address"></param>
        /// <param name="S_IP"></param>
        /// <returns></returns>
        public addressMatchResultEntity addressMatch(string address, string S_IP)
        {
            addressMatchResultEntity _addressMatchResult = new addressMatchResultEntity();
            _addressMatchResult.code = 200;
            string body = "";

            LogUtil.Info("getaddressMatch方法接收" + S_IP + "请求：address:{0}", address);

            try
            {
                DataTable dt = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "SELECT;WTB_GETADDRESSMATCH;" + address + "", "").Tables[0];//getaddressMatch(card_id,business_type, null);
                _addressMatchResult.isSuccess = false;
                List<add> addList = new List<add>();
                if (dt != null && dt.Rows.Count > 0 && dt.Rows[0]["MSGCODE"].ToString() == "00|")
                {
                    _addressMatchResult.isSuccess = true;
                    foreach (DataRow dr in dt.Rows)
                    {
                        add _address = new add();
                        _address.address = dr["S_DIZHI"].ToString();
                        _address.barcode = dr["S_SHUIBIAOTXM"].ToString();
                        _address.card_id = dr["S_CID"].ToString();
                        //addList.Add(dr["S_YUYUERQ"].ToString());
                        addList.Add(_address);
                    }
                    _addressMatchResult.addList = addList;
                }
                else
                {
                    _addressMatchResult.code = 500;
                    _addressMatchResult.errCode = "19";
                    _addressMatchResult.message = dt.Rows[0]["MSGCODE"].ToString().Split('|')[1];
                }
            }
            catch (Exception ex)
            {
                _addressMatchResult.errCode = "13";
                _addressMatchResult.code = 500;
                _addressMatchResult.message = ex.Message;
                LogUtil.Error("getaddressMatch方法异常：{0}", ex.Message);
                throw ex;
            }
            body = JsonConvert.SerializeObject(_addressMatchResult);
            LogUtil.Info("getaddressMatch方法返回" + S_IP + "结果：" + body);
            return _addressMatchResult;
        }

        /// <summary>
        /// 水表外移
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="S_IP"></param>
        /// <returns></returns>
        public XiangYingEntity meterMove(meterMoveEntity rpEntity, string S_IP)
        {
            string STR_CURRENT_COMPANY = ConfigurationManager.AppSettings["CURRENT_COMPANY"];
            string body = JsonConvert.SerializeObject(rpEntity);
            #region 定义变量
            int i_WsNo = (int)Web_Service_Name.Repair;//接口名称在枚举中对应的编号
            int i_code = 0;
            bool b_isGood = true;
            string s_result = string.Empty;//记录操作结果
            string message = "";//水务之声接口返回json串
            StringBuilder s_message = new StringBuilder();//记录参数和操作结果&方法参数
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_BAOXIUXX _outWTB_BAOXIUXX = new WTB_BAOXIUXX();
            XiangYingEntity _XiangYingEntity = new XiangYingEntity();
            #endregion

            try
            {

                #region 记录参数
                LogUtil.Info("meterMove方法接收" + S_IP + "请求：" + body);

                #endregion
                if (STR_CURRENT_COMPANY == "PDWLY")//判断当前公司是否为威立雅
                {
                    ResultEntity _entity = searchWaterUserInfo(rpEntity.card_id, "29", "", "1");//查询表卡信息
                    
                    string URL_BAOXIU_HOT = ConfigurationManager.AppSettings["URL_BAOXIU_HOT"];
                    string METHODNAME_HOT = ConfigurationManager.AppSettings["METHODNAME_MOVE_HOT"];
                    rpEntity.contact_value = rpEntity.contact_num;
                    rpEntity.address = _entity.shw_address;
                    body = JsonConvert.SerializeObject(rpEntity);
                    LogUtil.Info("meterMove方法开始转发请求：" + body);
                    message = _BusinessLogsticBase.QueryPostWebService(URL_BAOXIU_HOT, METHODNAME_HOT, body);//调水务之声接口
                    LogUtil.Info("meterMove方法接收" + URL_BAOXIU_HOT + "响应：" + message);
                }

                #region 验证该INCIDENT_ID记录是否已存在
                ////b_isGood = _BusinessLogsticBase.IsIncident_IDExist(rpEntity.incident_id);
                ////if (!b_isGood)
                ////{
                ////    i_code = 500;
                ////    s_result = string.Format("申请单号:{0}已存在", rpEntity.incident_id);
                ////    s_message.AppendFormat("申请单号:{0}已存在", rpEntity.incident_id);
                ////    return _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                ////}
                #endregion

                _BusinessLogsticBase.CreatemeterMoveEntity(rpEntity, out _outWTB_YEWUZB, out _outWTB_BAOXIUXX);

                ResultEntity _result = searchWaterUserInfo(_outWTB_YEWUZB.CARD_ID, _outWTB_YEWUZB.BUSINESS_TYPE, "", "0");//再次调用业务校验接口
                b_isGood = _result.isSuccess;
                if (!b_isGood)
                {
                    i_code = Convert.ToInt32(_result.errCode);
                    s_result = string.Format("申请单号:{0} 操作出现异常 {1}", rpEntity.incident_id, _result.message);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }

                #region 写入数据库
                //写入数据库主表
                b_isGood = _BusinessLogsticBase.IsMainInsGoodByID(_outWTB_YEWUZB);
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    ////return _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入子表
                b_isGood = _BusinessLogsticBase.IsChildInsGoodByResult(_outWTB_BAOXIUXX, _outWTB_YEWUZB.BUSINESS_TYPE);////需修改成string 类型
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_BAOXIUXX表新增失败", rpEntity.incident_id);
                    ////return _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入证件列表
                if (b_isGood)
                {
                    if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                    {
                        b_isGood = _BusinessLogsticBase.IsInsertCertListGood(rpEntity.CertList, _outWTB_YEWUZB);
                        if (!b_isGood)
                        {
                            i_code = 12;
                            s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 证件列表数和成功写入WTB_WENJIANXX表记录数不符", rpEntity.incident_id);
                            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            goto last;
                        }
                        else
                        {
                            i_code = 200;
                            s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                        }
                    }
                    else
                    {
                        i_code = 200;
                        s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                        s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                    }
                }
                //else
                //{
                //    i_code = 200;
                //    s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                //    s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                //}
                #endregion
            }
            catch (Exception ex)
            {
                i_code = 12;
                s_result = string.Format("申请单号：{0}操作出现异常", rpEntity.incident_id);
                s_message.AppendFormat("申请单号：{0}操作失败,错误：{1}", rpEntity.incident_id, ex.Message);
                ////return _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                goto last;
            }
            finally
            {

                //记日志
                LogUtil.Info(s_message.ToString());

            }
        last:
            if (STR_CURRENT_COMPANY == "PDWLY")//判断当前公司是否为威立雅
            {
                XiangYingEntity result = JsonConvert.DeserializeObject<XiangYingEntity>(message);
                LogUtil.Info("meterMove方法转发响应：" + message);
                return result;//_BusinessLogsticBase.GetXiangYingResult(i_code,s_result);
            }
            else
            {
                XiangYingEntity result = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                LogUtil.Info("meterMove方法响应：" + message);
                return result;
            }
        }

        /// <summary>
        /// 新表启封
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="S_IP"></param>
        /// <returns></returns>
        public XiangYingEntity meterUnseal(meterUnsealEntity rpEntity, string S_IP)
        {
            #region 定义变量
            string STR_CURRENT_COMPANY = ConfigurationManager.AppSettings["CURRENT_COMPANY"];
            int i_code = 0;
            bool b_isGood = true;
            string s_incident_type = "30";//此处为incident_type
            string s_result = string.Empty;//记录操作结果
            string body = "";
            StringBuilder s_message = new StringBuilder();
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_SHOULIXX _outWTB_SHOULIXX = new WTB_SHOULIXX();
            XiangYingEntity _XiangYingEntity = new XiangYingEntity();
            
            #endregion

            try
            {
                #region 记录参数
                //s_message.Append(_BusinessLogsticBase.GetParameterByMethod(i_WsNo, rpEntity));
                body = JsonConvert.SerializeObject(rpEntity);
                LogUtil.Info("meterUnseal方法接收" + S_IP + "请求：" + body);
                #endregion

                #region 验证参数
                //不能为空
                if (string.IsNullOrEmpty(rpEntity.incident_id)) { i_code = 11; s_result = "申请单唯一ID" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.source)) { i_code = 11; s_result = "提交渠道" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.apply_no)) { i_code = 11; s_result = "统一审批编码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.applicant)) { i_code = 11; s_result = "申请人" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.appdate)) { i_code = 11; s_result = "申请时间" + s_suffix_notEmpty; goto last; }
                
                
                if (string.IsNullOrEmpty(rpEntity.cert_type)) { i_code = 11; s_result = "申请人证件类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.cert_number)) { i_code = 11; s_result = "申请人证件号码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.fczjlx)) { i_code = 11; s_result = "房产证件类型" + s_suffix_notEmpty; goto last; }

                if (string.IsNullOrEmpty(rpEntity.fczjhm)) { i_code = 11; s_result = "房产证件号码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.address)) { i_code = 11; s_result = "用水地址" + s_suffix_notEmpty; goto last; }
                //if (string.IsNullOrEmpty(rpEntity.bdczl)) { i_code = 11; s_result = "不动产坐落" + s_suffix_notEmpty; goto last; }
                //if (string.IsNullOrEmpty(rpEntity.bdcdbrq)) { i_code = 11; s_result = "不动产登簿日期" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.contact_num)) { i_code = 11; s_result = "联系人电话" + s_suffix_notEmpty; goto last; }
                //if (string.IsNullOrEmpty(rpEntity.address)) { i_code = 11; s_result = "预约时间" + s_suffix_notEmpty; goto last; }//预约时间


                //验证列表
                if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                {
                    b_isGood = new BusinessLogsticBase().ValidateCertList(rpEntity.CertList, out s_result);
                    if (!b_isGood) { i_code = 11; goto last; }
                }

                #endregion

                #region 验证该INCIDENT_ID记录是否已存在
                b_isGood = _BusinessLogsticBase.IsIncident_IDExist(rpEntity.incident_id);
                if (!b_isGood)
                {
                    i_code = 9;
                    s_result = string.Format("申请单号:{0}已存在", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0}已存在", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                #endregion
                _BusinessLogsticBase.CreatemeterUnsealEntity(rpEntity, out _outWTB_YEWUZB, out _outWTB_SHOULIXX);

                
                ResultEntity _result = new ResultEntity();//searchWaterUserInfo(rpEntity.card_id, s_incident_type, S_IP, "0");//queryInvoice(_queryInvoiceEntity, S_IP);//再次调用验接口
                DataSet ds = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "SELECT;WTB_GETADDRESSMATCH;" + rpEntity.address, "");
                if (ds.Tables[0].Rows[0]["MSGCODE"].ToString() == "00|")
                {
                    _result.isSuccess = true;
                }
                else
                {
                    i_code = Convert.ToInt32(ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[0]);
                    s_result = string.Format("申请单号:{0} 操作出现异常 {1}", rpEntity.incident_id, ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[1]);
                    s_message.AppendFormat("申请单号:{0} 提交异常 {1}", rpEntity.incident_id, ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[1]);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }

                b_isGood = _result.isSuccess;
                if (!b_isGood)
                {
                    i_code = Convert.ToInt32(_result.errCode);
                    s_result = string.Format("申请单号:{0} 操作出现异常 {1}", rpEntity.incident_id, _result.message);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }

                #region 写入数据库
                //写入数据库主表
                b_isGood = _BusinessLogsticBase.IsMainInsGoodByID(_outWTB_YEWUZB);
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入子表
                b_isGood = _BusinessLogsticBase.IsChildInsGoodByResult(_outWTB_SHOULIXX, s_incident_type);
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_SHOULIXX表新增失败", rpEntity.incident_id);
                    _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入证件列表
                if (b_isGood)
                {
                    if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                    {
                        b_isGood = _BusinessLogsticBase.IsInsertCertListGood(rpEntity.CertList, _outWTB_YEWUZB);
                        if (!b_isGood)
                        {
                            i_code = 12;
                            s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 证件列表数和成功写入WTB_WENJIANXX表记录数不符", rpEntity.incident_id);
                            _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            goto last;
                        }
                        else
                        {
                            i_code = 200;
                            s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                            //if (STR_CURRENT_COMPANY == "PDWLY" || STR_CURRENT_COMPANY == "TRUE")//判断当前公司是否为威立雅
                            //{
                            //    string strParms = "";

                            //    strParms += rpEntity.user_name + ";";//V_USERNAME          VARCHAR2,
                            //    strParms += rpEntity.card_id + ";";//V_CID               VARCHAR2,
                            //    strParms += rpEntity.shw_address + ";";//v_shw_address       VARCHAR2,
                            //    strParms += rpEntity.nsrsbh + ";";//V_nsrsbh            VARCHAR2,
                            //    strParms += rpEntity.bill_month + ";";//V_bill_month        VARCHAR2,
                            //    strParms += rpEntity.money + ";";//V_money             NUMBER,
                            //    strParms += rpEntity.email + ";";//v_email             VARCHAR2,
                            //    strParms += rpEntity.contact_number + ";";//v_contact_number    VARCHAR2,
                            //    strParms += "一网通办" + ";";//V_CAOZUOR           VARCHAR2,
                            //    strParms += rpEntity.apply_no + ";";//V_YEWUBH            VARCHAR2,
                            //    strParms += rpEntity.incident_id + "";//v_incident_id         VARCHAR2,
                            //    DataTable dt_bgxx = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "INSERT;WTB_DZFAPIAOZDADD;" + strParms, "").Tables[0];//KEHUXXBG("2", rpEntity.card_id, kehulx, zhengjianlx, "", "", email, rpEntity.applicant, dianhua, shouji, "一网通办", rpEntity.incident_id, null);
                            //    if (dt_bgxx.Rows[0][0].ToString() != "00|")
                            //    {
                            //        i_code = 12;

                            //        s_message.Clear();
                            //        s_message.AppendFormat("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                            //        s_result = string.Format("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                            //        _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                            //        _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            //        goto last;
                            //    }
                            //    else
                            //    {
                            //        VatIvoService.VatIvoServiceClient vat = new VatIvoService.VatIvoServiceClient();
                            //        b_isGood = vat.QueryXml(rpEntity.card_id, rpEntity.user_name, rpEntity.shw_address, Convert.ToInt32(rpEntity.bill_month.Substring(0, 4)), Convert.ToInt32(rpEntity.bill_month.Substring(4, 2)), Convert.ToDecimal(rpEntity.money), rpEntity.nsrsbh, rpEntity.contact_number, rpEntity.email, "一网通办", 1, out s_result);
                            //        if (!b_isGood)
                            //        {
                            //            i_code = 12;
                            //            s_message.Clear();
                            //            //s_result = string.Format("申请单号:{0} 办理失败", rpEntity.incident_id);
                            //            s_message.AppendFormat("申请单号:{0} 办理失败{1}", rpEntity.incident_id, s_result);
                            //            s_result = string.Format("申请单号:{0} 办理失败{1}", rpEntity.incident_id, s_result);
                            //            _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                            //            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            //            goto last;
                            //        }
                            //    }
                            //}
                        }
                    }
                    else
                    {
                        i_code = 200;
                        s_message.Clear();
                        s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                        s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                        //if (STR_CURRENT_COMPANY == "PDWLY" || STR_CURRENT_COMPANY == "TRUE")//判断当前公司是否为威立雅
                        //{
                        //    string strParms = "";
                        //    strParms += rpEntity.user_name + ";";//V_USERNAME          VARCHAR2,
                        //    strParms += rpEntity.card_id + ";";//V_CID               VARCHAR2,
                        //    strParms += rpEntity.shw_address + ";";//v_shw_address       VARCHAR2,
                        //    strParms += rpEntity.nsrsbh + ";";//V_nsrsbh            VARCHAR2,
                        //    strParms += rpEntity.bill_month + ";";//V_bill_month        VARCHAR2,
                        //    strParms += rpEntity.money + ";";//V_money             NUMBER,
                        //    strParms += rpEntity.email + ";";//v_email             VARCHAR2,
                        //    strParms += rpEntity.contact_number + ";";//v_contact_number    VARCHAR2,
                        //    strParms += "一网通办" + ";";//V_CAOZUOR           VARCHAR2,
                        //    strParms += rpEntity.apply_no + ";";//V_YEWUBH            VARCHAR2,
                        //    strParms += rpEntity.incident_id + "";//v_incident_id         VARCHAR2,

                        //    DataTable dt_bgxx = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "INSERT;WTB_DZFAPIAOZDADD;" + strParms, "").Tables[0];//KEHUXXBG("2", rpEntity.card_id, kehulx, zhengjianlx, "", "", email, rpEntity.applicant, dianhua, shouji, "一网通办", rpEntity.incident_id, null);
                        //    if (dt_bgxx.Rows[0][0].ToString() != "00|")
                        //    {
                        //        i_code = 12;
                        //        //s_result = string.Format("申请单号:{0} 办理失败", rpEntity.incident_id);
                        //        //s_message.AppendFormat("申请单号:{0} 办理失败", rpEntity.incident_id);

                        //        s_message.Clear();
                        //        s_message.AppendFormat("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                        //        s_result = string.Format("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                        //        _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                        //        _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                        //        goto last;
                        //    }
                        //    else
                        //    {
                        //        VatIvoService.VatIvoServiceClient vat = new VatIvoService.VatIvoServiceClient();
                        //        b_isGood = vat.QueryXml(rpEntity.card_id, rpEntity.user_name, rpEntity.shw_address, Convert.ToInt32(rpEntity.bill_month.Substring(0, 4)), Convert.ToInt32(rpEntity.bill_month.Substring(4, 2)), Convert.ToDecimal(rpEntity.money), rpEntity.nsrsbh, rpEntity.contact_number, rpEntity.email, "一网通办", 1, out s_result);
                        //        if (!b_isGood)
                        //        {
                        //            i_code = 12;
                        //            //s_result = string.Format("申请单号:{0} 办理失败", rpEntity.incident_id);
                        //            s_message.Clear();
                        //            s_message.AppendFormat("申请单号:{0} 办理失败{1}", rpEntity.incident_id, s_result);
                        //            s_result = string.Format("申请单号:{0} 办理失败{1}", rpEntity.incident_id, s_result);
                        //            _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                        //            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                        //            goto last;
                        //        }

                        //    }
                        //}
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                i_code = 12;
                s_message.Clear();
                s_result = string.Format("申请单号：{0} 操作出现异常", rpEntity.incident_id);
                s_message.AppendFormat("申请单号：{0}操作失败,错误：{1}", rpEntity.incident_id, ex.Message);
                _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                goto last;
            }
            finally
            {
                //记日志
                LogUtil.Info(s_message.ToString());
            }
        last:
            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
            _XiangYingEntity.incident_id = rpEntity.incident_id;
            body = JsonConvert.SerializeObject(_XiangYingEntity);
            LogUtil.Info("meterUnseal方法返回" + S_IP + "结果：" + body);
            return _XiangYingEntity;
        }

        /// <summary>
        /// 水表拆除销户
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="S_IP"></param>
        /// <returns></returns>
        public XiangYingEntity accountCancel(accountCancelEntity rpEntity, string S_IP)
        {
            #region 定义变量
            string STR_CURRENT_COMPANY = ConfigurationManager.AppSettings["CURRENT_COMPANY"];
            int i_code = 0;
            bool b_isGood = true;
            string s_incident_type = "31";//此处为incident_type
            string s_result = string.Empty;//记录操作结果
            string body = "";
            StringBuilder s_message = new StringBuilder();
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_SHOULIXX _outWTB_SHOULIXX = new WTB_SHOULIXX();
            XiangYingEntity _XiangYingEntity = new XiangYingEntity();

            #endregion

            try
            {
                #region 记录参数
                //s_message.Append(_BusinessLogsticBase.GetParameterByMethod(i_WsNo, rpEntity));
                body = JsonConvert.SerializeObject(rpEntity);
                LogUtil.Info("accountCancel方法接收" + S_IP + "请求：" + body);
                #endregion

                #region 验证参数
                //不能为空
                if (string.IsNullOrEmpty(rpEntity.incident_id)) { i_code = 11; s_result = "申请单唯一ID" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.source)) { i_code = 11; s_result = "提交渠道" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.apply_no)) { i_code = 11; s_result = "统一审批编码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.applicant)) { i_code = 11; s_result = "申请人" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.appdate)) { i_code = 11; s_result = "申请时间" + s_suffix_notEmpty; goto last; }

                if (string.IsNullOrEmpty(rpEntity.cert_type)) { i_code = 11; s_result = "申请人证件类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.cert_number)) { i_code = 11; s_result = "申请人证件号码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.nsrsbh)) { i_code = 11; s_result = "纳税人识别号" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.card_id)) { i_code = 11; s_result = "销根号" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.fczjlx)) { i_code = 11; s_result = "房产证件类型" + s_suffix_notEmpty; goto last; }

                if (string.IsNullOrEmpty(rpEntity.fczjhm)) { i_code = 11; s_result = "房产证件号码" + s_suffix_notEmpty; goto last; }

                if (string.IsNullOrEmpty(rpEntity.address)) { i_code = 11; s_result = "用水地址" + s_suffix_notEmpty; goto last; }
                //if (string.IsNullOrEmpty(rpEntity.bdczl)) { i_code = 11; s_result = "不动产坐落" + s_suffix_notEmpty; goto last; }
                //if (string.IsNullOrEmpty(rpEntity.bdcdbrq)) { i_code = 11; s_result = "不动产登簿日期" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.reason)) { i_code = 11; s_result = "销户原因" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.contact_num)) { i_code = 11; s_result = "联系人电话" + s_suffix_notEmpty; goto last; }
                //if (string.IsNullOrEmpty(rpEntity.bookTime)) { i_code = 11; s_result = "预约时间" + s_suffix_notEmpty; goto last; }//预约时间


                //验证列表
                if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                {
                    b_isGood = new BusinessLogsticBase().ValidateCertList(rpEntity.CertList, out s_result);
                    if (!b_isGood) { i_code = 11; goto last; }
                }

                #endregion

                #region 验证该INCIDENT_ID记录是否已存在
                b_isGood = _BusinessLogsticBase.IsIncident_IDExist(rpEntity.incident_id);
                if (!b_isGood)
                {
                    i_code = 9;
                    s_result = string.Format("申请单号:{0}已存在", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0}已存在", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                #endregion
                _BusinessLogsticBase.CreateaccountCancelEntity(rpEntity, out _outWTB_YEWUZB, out _outWTB_SHOULIXX);


                ResultEntity _result = searchWaterUserInfo(rpEntity.card_id, s_incident_type, S_IP, "0");//queryInvoice(_queryInvoiceEntity, S_IP);//再次调用验接口
                b_isGood = _result.isSuccess;
                if (!b_isGood)
                {
                    i_code = Convert.ToInt32(_result.errCode);
                    s_result = string.Format("申请单号:{0} 操作出现异常 {1}", rpEntity.incident_id, _result.message);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }

                #region 写入数据库
                //写入数据库主表
                b_isGood = _BusinessLogsticBase.IsMainInsGoodByID(_outWTB_YEWUZB);
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入子表
                b_isGood = _BusinessLogsticBase.IsChildInsGoodByResult(_outWTB_SHOULIXX, s_incident_type);
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_SHOULIXX表新增失败", rpEntity.incident_id);
                    _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入证件列表
                if (b_isGood)
                {
                    if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                    {
                        b_isGood = _BusinessLogsticBase.IsInsertCertListGood(rpEntity.CertList, _outWTB_YEWUZB);
                        if (!b_isGood)
                        {
                            i_code = 12;
                            s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 证件列表数和成功写入WTB_WENJIANXX表记录数不符", rpEntity.incident_id);
                            _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            goto last;
                        }
                        else
                        {
                            i_code = 200;
                            s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                            //if (STR_CURRENT_COMPANY == "PDWLY" || STR_CURRENT_COMPANY == "TRUE")//判断当前公司是否为威立雅
                            //{
                            //    string strParms = "";

                            //    strParms += rpEntity.user_name + ";";//V_USERNAME          VARCHAR2,
                            //    strParms += rpEntity.card_id + ";";//V_CID               VARCHAR2,
                            //    strParms += rpEntity.shw_address + ";";//v_shw_address       VARCHAR2,
                            //    strParms += rpEntity.nsrsbh + ";";//V_nsrsbh            VARCHAR2,
                            //    strParms += rpEntity.bill_month + ";";//V_bill_month        VARCHAR2,
                            //    strParms += rpEntity.money + ";";//V_money             NUMBER,
                            //    strParms += rpEntity.email + ";";//v_email             VARCHAR2,
                            //    strParms += rpEntity.contact_number + ";";//v_contact_number    VARCHAR2,
                            //    strParms += "一网通办" + ";";//V_CAOZUOR           VARCHAR2,
                            //    strParms += rpEntity.apply_no + ";";//V_YEWUBH            VARCHAR2,
                            //    strParms += rpEntity.incident_id + "";//v_incident_id         VARCHAR2,
                            //    DataTable dt_bgxx = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "INSERT;WTB_DZFAPIAOZDADD;" + strParms, "").Tables[0];//KEHUXXBG("2", rpEntity.card_id, kehulx, zhengjianlx, "", "", email, rpEntity.applicant, dianhua, shouji, "一网通办", rpEntity.incident_id, null);
                            //    if (dt_bgxx.Rows[0][0].ToString() != "00|")
                            //    {
                            //        i_code = 12;

                            //        s_message.Clear();
                            //        s_message.AppendFormat("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                            //        s_result = string.Format("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                            //        _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                            //        _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            //        goto last;
                            //    }
                            //    else
                            //    {
                            //        VatIvoService.VatIvoServiceClient vat = new VatIvoService.VatIvoServiceClient();
                            //        b_isGood = vat.QueryXml(rpEntity.card_id, rpEntity.user_name, rpEntity.shw_address, Convert.ToInt32(rpEntity.bill_month.Substring(0, 4)), Convert.ToInt32(rpEntity.bill_month.Substring(4, 2)), Convert.ToDecimal(rpEntity.money), rpEntity.nsrsbh, rpEntity.contact_number, rpEntity.email, "一网通办", 1, out s_result);
                            //        if (!b_isGood)
                            //        {
                            //            i_code = 12;
                            //            s_message.Clear();
                            //            //s_result = string.Format("申请单号:{0} 办理失败", rpEntity.incident_id);
                            //            s_message.AppendFormat("申请单号:{0} 办理失败{1}", rpEntity.incident_id, s_result);
                            //            s_result = string.Format("申请单号:{0} 办理失败{1}", rpEntity.incident_id, s_result);
                            //            _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                            //            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            //            goto last;
                            //        }
                            //    }
                            //}
                        }
                    }
                    else
                    {
                        i_code = 200;
                        s_message.Clear();
                        s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                        s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                        //if (STR_CURRENT_COMPANY == "PDWLY" || STR_CURRENT_COMPANY == "TRUE")//判断当前公司是否为威立雅
                        //{
                        //    string strParms = "";
                        //    strParms += rpEntity.user_name + ";";//V_USERNAME          VARCHAR2,
                        //    strParms += rpEntity.card_id + ";";//V_CID               VARCHAR2,
                        //    strParms += rpEntity.shw_address + ";";//v_shw_address       VARCHAR2,
                        //    strParms += rpEntity.nsrsbh + ";";//V_nsrsbh            VARCHAR2,
                        //    strParms += rpEntity.bill_month + ";";//V_bill_month        VARCHAR2,
                        //    strParms += rpEntity.money + ";";//V_money             NUMBER,
                        //    strParms += rpEntity.email + ";";//v_email             VARCHAR2,
                        //    strParms += rpEntity.contact_number + ";";//v_contact_number    VARCHAR2,
                        //    strParms += "一网通办" + ";";//V_CAOZUOR           VARCHAR2,
                        //    strParms += rpEntity.apply_no + ";";//V_YEWUBH            VARCHAR2,
                        //    strParms += rpEntity.incident_id + "";//v_incident_id         VARCHAR2,

                        //    DataTable dt_bgxx = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "INSERT;WTB_DZFAPIAOZDADD;" + strParms, "").Tables[0];//KEHUXXBG("2", rpEntity.card_id, kehulx, zhengjianlx, "", "", email, rpEntity.applicant, dianhua, shouji, "一网通办", rpEntity.incident_id, null);
                        //    if (dt_bgxx.Rows[0][0].ToString() != "00|")
                        //    {
                        //        i_code = 12;
                        //        //s_result = string.Format("申请单号:{0} 办理失败", rpEntity.incident_id);
                        //        //s_message.AppendFormat("申请单号:{0} 办理失败", rpEntity.incident_id);

                        //        s_message.Clear();
                        //        s_message.AppendFormat("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                        //        s_result = string.Format("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                        //        _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                        //        _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                        //        goto last;
                        //    }
                        //    else
                        //    {
                        //        VatIvoService.VatIvoServiceClient vat = new VatIvoService.VatIvoServiceClient();
                        //        b_isGood = vat.QueryXml(rpEntity.card_id, rpEntity.user_name, rpEntity.shw_address, Convert.ToInt32(rpEntity.bill_month.Substring(0, 4)), Convert.ToInt32(rpEntity.bill_month.Substring(4, 2)), Convert.ToDecimal(rpEntity.money), rpEntity.nsrsbh, rpEntity.contact_number, rpEntity.email, "一网通办", 1, out s_result);
                        //        if (!b_isGood)
                        //        {
                        //            i_code = 12;
                        //            //s_result = string.Format("申请单号:{0} 办理失败", rpEntity.incident_id);
                        //            s_message.Clear();
                        //            s_message.AppendFormat("申请单号:{0} 办理失败{1}", rpEntity.incident_id, s_result);
                        //            s_result = string.Format("申请单号:{0} 办理失败{1}", rpEntity.incident_id, s_result);
                        //            _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                        //            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                        //            goto last;
                        //        }

                        //    }
                        //}
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                i_code = 12;
                s_message.Clear();
                s_result = string.Format("申请单号：{0} 操作出现异常", rpEntity.incident_id);
                s_message.AppendFormat("申请单号：{0}操作失败,错误：{1}", rpEntity.incident_id, ex.Message);
                _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                goto last;
            }
            finally
            {
                //记日志
                LogUtil.Info(s_message.ToString());
            }
        last:
            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
            _XiangYingEntity.incident_id = rpEntity.incident_id;
            body = JsonConvert.SerializeObject(_XiangYingEntity);
            LogUtil.Info("accountCancel方法返回" + S_IP + "结果：" + body);
            return _XiangYingEntity;
        }

        /// <summary>
        /// 合用表
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="S_IP"></param>
        /// <returns></returns>
        public XiangYingEntity shareMeter(shareMeterEntity rpEntity, string S_IP)
        {
            #region 定义变量
            string STR_CURRENT_COMPANY = ConfigurationManager.AppSettings["CURRENT_COMPANY"];
            int i_code = 0;
            bool b_isGood = true;
            string s_incident_type = "32";//此处为incident_type
            string s_result = string.Empty;//记录操作结果
            string body = "";
            StringBuilder s_message = new StringBuilder();
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_HEYONGBXX _outWTB_HEYONGBXX = new WTB_HEYONGBXX();
            XiangYingEntity _XiangYingEntity = new XiangYingEntity();

            #endregion

            try
            {
                #region 记录参数
                //s_message.Append(_BusinessLogsticBase.GetParameterByMethod(i_WsNo, rpEntity));
                body = JsonConvert.SerializeObject(rpEntity);
                LogUtil.Info("shareMeter方法接收" + S_IP + "请求：" + body);
                #endregion

                #region 验证参数
                //不能为空
                if (string.IsNullOrEmpty(rpEntity.incident_id)) { i_code = 11; s_result = "申请单唯一ID" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.source)) { i_code = 11; s_result = "提交渠道" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.apply_no)) { i_code = 11; s_result = "统一审批编码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.applicant)) { i_code = 11; s_result = "申请人" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.appdate)) { i_code = 11; s_result = "申请时间" + s_suffix_notEmpty; goto last; }

                if (string.IsNullOrEmpty(rpEntity.cert_type)) { i_code = 11; s_result = "申请人证件类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.cert_number)) { i_code = 11; s_result = "申请人证件号码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.contact_num)) { i_code = 11; s_result = "联系人电话" + s_suffix_notEmpty; goto last; }

                if (string.IsNullOrEmpty(rpEntity.req_type)) { i_code = 11; s_result = "办理类型" + s_suffix_notEmpty; goto last; }
                if (rpEntity.req_type!="01"/*&&rpEntity.req_type!="02"*/) { i_code = 11; s_result = "无此办理类型" ; goto last; }

                if (string.IsNullOrEmpty(rpEntity.card_id)) { i_code = 11; s_result = "销根号" + s_suffix_notEmpty; goto last; }

                if (string.IsNullOrEmpty(rpEntity.bookletNum)) { i_code = 11; s_result = "户口簿数量" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.address)) { i_code = 11; s_result = "用水地址" + s_suffix_notEmpty; goto last; }
                
                //验证列表
                if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                {
                    b_isGood = new BusinessLogsticBase().ValidateCertList(rpEntity.CertList, out s_result);
                    if (!b_isGood) { i_code = 11; goto last; }
                }

                #endregion

                #region 验证该INCIDENT_ID记录是否已存在
                b_isGood = _BusinessLogsticBase.IsIncident_IDExist(rpEntity.incident_id);
                if (!b_isGood)
                {
                    i_code = 9;
                    s_result = string.Format("申请单号:{0}已存在", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0}已存在", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                #endregion
                _BusinessLogsticBase.CreateshareMeterEntity(rpEntity, out _outWTB_YEWUZB, out _outWTB_HEYONGBXX);


                ResultEntity _result = searchWaterUserInfo(rpEntity.card_id, s_incident_type, S_IP, "0");//queryInvoice(_queryInvoiceEntity, S_IP);//再次调用验接口
                
                b_isGood = _result.isSuccess;
                if (!b_isGood)
                {
                    i_code = Convert.ToInt32(_result.errCode);
                    s_result = string.Format("申请单号:{0} 操作出现异常 {1}", rpEntity.incident_id, _result.message);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }

                #region 写入数据库
                //写入数据库主表
                b_isGood = _BusinessLogsticBase.IsMainInsGoodByID(_outWTB_YEWUZB);
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入子表
                b_isGood = _BusinessLogsticBase.IsChildInsGoodByResult(_outWTB_HEYONGBXX, s_incident_type);
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_HEYONGBXX表新增失败", rpEntity.incident_id);
                    _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入证件列表
                if (b_isGood)
                {
                    if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                    {
                        b_isGood = _BusinessLogsticBase.IsInsertCertListGood(rpEntity.CertList, _outWTB_YEWUZB);
                        if (!b_isGood)
                        {
                            i_code = 12;
                            s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 证件列表数和成功写入WTB_WENJIANXX表记录数不符", rpEntity.incident_id);
                            _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            goto last;
                        }

                    }

                    i_code = 200;
                    s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                    //if (STR_CURRENT_COMPANY == "PDWLY" || STR_CURRENT_COMPANY == "TRUE")//判断当前公司是否为威立雅
                    //{
                    string strCS = "";
                    strCS += rpEntity.incident_id + ";";//V_incident_id
                    strCS += _outWTB_HEYONGBXX.REQ_TYPE + ";";//V_LEIXING
                    strCS += _outWTB_YEWUZB.CARD_ID + ";";//V_CID
                    strCS += "H" + ";";//V_FANGAN
                    strCS += _outWTB_HEYONGBXX.BOOKLETNUM + ";";//V_RENKOUS
                    strCS += "一网通办" + "";//V_CAOZUOR

                    LogUtil.Info("WTB_DUORENKFF 处理{0}", strCS);
                    DataTable dt_bgxx = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "UPDATE;WTB_HEYONGBFF;" + strCS, "").Tables[0]; //_AccessDataBase.WTB_DUORENKFF("1", rpEntity.card_id, kehulx, zhengjianlx, rpEntity.id_nbr, rpEntity.entity_name, "", rpEntity.applicant, dianhua, shouji, "一网通办", rpEntity.incident_id, null);
                    if (dt_bgxx.Rows[0][0].ToString() != "00|")
                    {
                        i_code = 12;
                        s_message.Clear();
                        s_message.AppendFormat("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                        s_result = string.Format("申请单号:{0} 办理失败", rpEntity.incident_id);
                        _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                        _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                        goto last;
                    }
                    //}

                }
                #endregion
            }
            catch (Exception ex)
            {
                i_code = 12;
                s_message.Clear();
                s_result = string.Format("申请单号：{0} 操作出现异常", rpEntity.incident_id);
                s_message.AppendFormat("申请单号：{0}操作失败,错误：{1}", rpEntity.incident_id, ex.Message);
                _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                goto last;
            }
            finally
            {
                //记日志
                LogUtil.Info(s_message.ToString());
            }
        last:
            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
            _XiangYingEntity.incident_id = rpEntity.incident_id;
            body = JsonConvert.SerializeObject(_XiangYingEntity);
            LogUtil.Info("shareMeter方法返回" + S_IP + "结果：" + body);
            return _XiangYingEntity;
        }

        /// <summary>
        /// 获取户号列表
        /// </summary>
        /// <param name="card_id"></param>
        /// <param name="S_IP"></param>
        /// <returns></returns>
        public cardListResultEntity cardList(string card_id, string S_IP)
        {
            cardListResultEntity _cardListResult = new cardListResultEntity();
            _cardListResult.code = 200;
            string body = "";

            LogUtil.Info("cardList方法接收" + S_IP + "请求：card_id:{0}", card_id);

            try
            {
                DataTable dt = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "SELECT;WTB_GETCARDLIST;" + card_id + "", "").Tables[1];//getcardList(card_id,business_type, null);
                _cardListResult.isSuccess = false;
                List<add> addList = new List<add>();
                if (dt != null && dt.Rows.Count > 0)
                {
                    _cardListResult.isSuccess = true;
                    foreach (DataRow dr in dt.Rows)
                    {
                        add _address = new add();
                        _address.address = dr["S_DIZHI"].ToString();
                        _address.barcode = dr["S_SHUIBIAOTXM"].ToString();
                        _address.card_id = dr["S_CID"].ToString();
                        //addList.Add(dr["S_YUYUERQ"].ToString());
                        addList.Add(_address);
                    }
                    _cardListResult.cardList = addList;
                }
                else
                {
                    _cardListResult.errCode = "01";
                    _cardListResult.message = "销根号不存在";
                }
            }
            catch (Exception ex)
            {
                _cardListResult.errCode = "13";
                _cardListResult.code = 500;
                _cardListResult.message = ex.Message;
                throw ex;
            }
            body = JsonConvert.SerializeObject(_cardListResult);
            LogUtil.Info("cardList方法返回" + S_IP + "结果：" + body);
            return _cardListResult;
        }

        /// <summary>
        /// 水费托收
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="S_IP"></param>
        /// <returns></returns>
        public XiangYingEntity chargeCollection(chargeCollectionEntity rpEntity, string S_IP)
        {
            #region 定义变量
            string STR_CURRENT_COMPANY = ConfigurationManager.AppSettings["CURRENT_COMPANY"];
            int i_code = 0;
            bool b_isGood = true;
            string s_incident_type = "33";//此处为incident_type
            string s_result = string.Empty;//记录操作结果
            string body = "";
            StringBuilder s_message = new StringBuilder();
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_SHOULIXX _outWTB_SHOULIXX = new WTB_SHOULIXX();
            XiangYingEntity _XiangYingEntity = new XiangYingEntity();

            #endregion

            try
            {
                #region 记录参数
                //s_message.Append(_BusinessLogsticBase.GetParameterByMethod(i_WsNo, rpEntity));
                body = JsonConvert.SerializeObject(rpEntity);
                LogUtil.Info("chargeCollection方法接收" + S_IP + "请求：" + body);
                #endregion

                #region 验证参数
                //不能为空
                if (string.IsNullOrEmpty(rpEntity.incident_id)) { i_code = 11; s_result = "申请单唯一ID" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.source)) { i_code = 11; s_result = "提交渠道" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.apply_no)) { i_code = 11; s_result = "统一审批编码 " + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.applicant)) { i_code = 11; s_result = "申请人" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.appdate)) { i_code = 11; s_result = "申请时间" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.cert_type)) { i_code = 11; s_result = "申请人证件类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.cert_number)) { i_code = 11; s_result = "申请人证件号码" + s_suffix_notEmpty; goto last; }
                //if (string.IsNullOrEmpty(rpEntity.company_name)) { i_code = 11; s_result = "企业名称" + s_suffix_notEmpty; goto last; }
                //if (string.IsNullOrEmpty(rpEntity.company_type)) { i_code = 11; s_result = "企业类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.nsrsbh)) { i_code = 11; s_result = "纳税人识别号" + s_suffix_notEmpty; goto last; }
                //if (string.IsNullOrEmpty(rpEntity.email)) { i_code = 11; s_result = "	电子邮箱	 " + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.card_id)) { i_code = 11; s_result = "销根号/账户编号/用户号" + s_suffix_notEmpty; goto last; }
                //if (string.IsNullOrEmpty(rpEntity.fczjlx)) { i_code = 11; s_result = "房产证件类型" + s_suffix_notEmpty; goto last; } 接口文档4.8说明不需要产证。
                //if (string.IsNullOrEmpty(rpEntity.fczjhm)) { i_code = 11; s_result = "房产证件号码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.address)) { i_code = 11; s_result = "用水地址" + s_suffix_notEmpty; goto last; }
                //if (string.IsNullOrEmpty(rpEntity.bdczl)) { i_code = 11; s_result = "不动产坐落" + s_suffix_notEmpty; goto last; }
                //if (string.IsNullOrEmpty(rpEntity.bdcdbrq)) { i_code = 11; s_result = "不动产登簿日期" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.contact_num)) { i_code = 11; s_result = "联系人电话" + s_suffix_notEmpty; goto last; }
                if (rpEntity.cardList.Count <= 0) { i_code = 11; s_result = "销根号列表" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.bank_account)) { i_code = 11; s_result = "银行账户" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.account_name)) { i_code = 11; s_result = "银行户名" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.bank)) { i_code = 11; s_result = "托收银行" + s_suffix_notEmpty; goto last; }



                //验证列表
                if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                {
                    b_isGood = new BusinessLogsticBase().ValidateCertList(rpEntity.CertList, out s_result);
                    if (!b_isGood) { i_code = 11; goto last; }
                }

                #endregion

                #region 验证该INCIDENT_ID记录是否已存在
                b_isGood = _BusinessLogsticBase.IsIncident_IDExist(rpEntity.incident_id);
                if (!b_isGood)
                {
                    i_code = 9;
                    s_result = string.Format("申请单号:{0}已存在", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0}已存在", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                #endregion
                _BusinessLogsticBase.CreatechargeCollectionEntity(rpEntity, out _outWTB_YEWUZB, out _outWTB_SHOULIXX);


                ResultEntity _result = searchWaterUserInfo(rpEntity.card_id, s_incident_type, S_IP, "0");//queryInvoice(_queryInvoiceEntity, S_IP);//再次调用验接口
                b_isGood = _result.isSuccess;
                if (!b_isGood)
                {
                    i_code = Convert.ToInt32(_result.errCode);
                    s_result = string.Format("申请单号:{0} 操作出现异常 {1}", rpEntity.incident_id, _result.message);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }

                #region 写入数据库
                //写入数据库主表
                b_isGood = _BusinessLogsticBase.IsMainInsGoodByID(_outWTB_YEWUZB);
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入子表
                b_isGood = _BusinessLogsticBase.IsChildInsGoodByResult(_outWTB_SHOULIXX, s_incident_type);
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_SHOULIXX表新增失败", rpEntity.incident_id);
                    _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入证件列表
                if (b_isGood)
                {
                    if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                    {
                        b_isGood = _BusinessLogsticBase.IsInsertCertListGood(rpEntity.CertList, _outWTB_YEWUZB);
                        if (!b_isGood)
                        {
                            i_code = 12;
                            s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 证件列表数和成功写入WTB_WENJIANXX表记录数不符", rpEntity.incident_id);
                            _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            goto last;
                        }
                        else
                        {
                            i_code = 200;
                            s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                            #region 不用逻辑
                            //if (STR_CURRENT_COMPANY == "PDWLY" || STR_CURRENT_COMPANY == "TRUE")//判断当前公司是否为威立雅
                            //{
                            //    string strParms = "";

                            //    strParms += rpEntity.user_name + ";";//V_USERNAME          VARCHAR2,
                            //    strParms += rpEntity.card_id + ";";//V_CID               VARCHAR2,
                            //    strParms += rpEntity.shw_address + ";";//v_shw_address       VARCHAR2,
                            //    strParms += rpEntity.nsrsbh + ";";//V_nsrsbh            VARCHAR2,
                            //    strParms += rpEntity.bill_month + ";";//V_bill_month        VARCHAR2,
                            //    strParms += rpEntity.money + ";";//V_money             NUMBER,
                            //    strParms += rpEntity.email + ";";//v_email             VARCHAR2,
                            //    strParms += rpEntity.contact_number + ";";//v_contact_number    VARCHAR2,
                            //    strParms += "一网通办" + ";";//V_CAOZUOR           VARCHAR2,
                            //    strParms += rpEntity.apply_no + ";";//V_YEWUBH            VARCHAR2,
                            //    strParms += rpEntity.incident_id + "";//v_incident_id         VARCHAR2,
                            //    DataTable dt_bgxx = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "INSERT;WTB_DZFAPIAOZDADD;" + strParms, "").Tables[0];//KEHUXXBG("2", rpEntity.card_id, kehulx, zhengjianlx, "", "", email, rpEntity.applicant, dianhua, shouji, "一网通办", rpEntity.incident_id, null);
                            //    if (dt_bgxx.Rows[0][0].ToString() != "00|")
                            //    {
                            //        i_code = 12;

                            //        s_message.Clear();
                            //        s_message.AppendFormat("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                            //        s_result = string.Format("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                            //        _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                            //        _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            //        goto last;
                            //    }
                            //    else
                            //    {
                            //        VatIvoService.VatIvoServiceClient vat = new VatIvoService.VatIvoServiceClient();
                            //        b_isGood = vat.QueryXml(rpEntity.card_id, rpEntity.user_name, rpEntity.shw_address, Convert.ToInt32(rpEntity.bill_month.Substring(0, 4)), Convert.ToInt32(rpEntity.bill_month.Substring(4, 2)), Convert.ToDecimal(rpEntity.money), rpEntity.nsrsbh, rpEntity.contact_number, rpEntity.email, "一网通办", 1, out s_result);
                            //        if (!b_isGood)
                            //        {
                            //            i_code = 12;
                            //            s_message.Clear();
                            //            //s_result = string.Format("申请单号:{0} 办理失败", rpEntity.incident_id);
                            //            s_message.AppendFormat("申请单号:{0} 办理失败{1}", rpEntity.incident_id, s_result);
                            //            s_result = string.Format("申请单号:{0} 办理失败{1}", rpEntity.incident_id, s_result);
                            //            _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                            //            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            //            goto last;
                            //        }
                            //    }
                            //}
                            #endregion
                        }
                    }
                    else
                    {
                        i_code = 200;
                        s_message.Clear();
                        s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                        s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                        #region 不用逻辑
                        //if (STR_CURRENT_COMPANY == "PDWLY" || STR_CURRENT_COMPANY == "TRUE")//判断当前公司是否为威立雅
                        //{
                        //    string strParms = "";
                        //    strParms += rpEntity.user_name + ";";//V_USERNAME          VARCHAR2,
                        //    strParms += rpEntity.card_id + ";";//V_CID               VARCHAR2,
                        //    strParms += rpEntity.shw_address + ";";//v_shw_address       VARCHAR2,
                        //    strParms += rpEntity.nsrsbh + ";";//V_nsrsbh            VARCHAR2,
                        //    strParms += rpEntity.bill_month + ";";//V_bill_month        VARCHAR2,
                        //    strParms += rpEntity.money + ";";//V_money             NUMBER,
                        //    strParms += rpEntity.email + ";";//v_email             VARCHAR2,
                        //    strParms += rpEntity.contact_number + ";";//v_contact_number    VARCHAR2,
                        //    strParms += "一网通办" + ";";//V_CAOZUOR           VARCHAR2,
                        //    strParms += rpEntity.apply_no + ";";//V_YEWUBH            VARCHAR2,
                        //    strParms += rpEntity.incident_id + "";//v_incident_id         VARCHAR2,

                        //    DataTable dt_bgxx = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "INSERT;WTB_DZFAPIAOZDADD;" + strParms, "").Tables[0];//KEHUXXBG("2", rpEntity.card_id, kehulx, zhengjianlx, "", "", email, rpEntity.applicant, dianhua, shouji, "一网通办", rpEntity.incident_id, null);
                        //    if (dt_bgxx.Rows[0][0].ToString() != "00|")
                        //    {
                        //        i_code = 12;
                        //        //s_result = string.Format("申请单号:{0} 办理失败", rpEntity.incident_id);
                        //        //s_message.AppendFormat("申请单号:{0} 办理失败", rpEntity.incident_id);

                        //        s_message.Clear();
                        //        s_message.AppendFormat("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                        //        s_result = string.Format("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                        //        _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                        //        _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                        //        goto last;
                        //    }
                        //    else
                        //    {
                        //        VatIvoService.VatIvoServiceClient vat = new VatIvoService.VatIvoServiceClient();
                        //        b_isGood = vat.QueryXml(rpEntity.card_id, rpEntity.user_name, rpEntity.shw_address, Convert.ToInt32(rpEntity.bill_month.Substring(0, 4)), Convert.ToInt32(rpEntity.bill_month.Substring(4, 2)), Convert.ToDecimal(rpEntity.money), rpEntity.nsrsbh, rpEntity.contact_number, rpEntity.email, "一网通办", 1, out s_result);
                        //        if (!b_isGood)
                        //        {
                        //            i_code = 12;
                        //            //s_result = string.Format("申请单号:{0} 办理失败", rpEntity.incident_id);
                        //            s_message.Clear();
                        //            s_message.AppendFormat("申请单号:{0} 办理失败{1}", rpEntity.incident_id, s_result);
                        //            s_result = string.Format("申请单号:{0} 办理失败{1}", rpEntity.incident_id, s_result);
                        //            _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                        //            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                        //            goto last;
                        //        }

                        //    }
                        //}
                        #endregion
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                i_code = 12;
                s_message.Clear();
                s_result = string.Format("申请单号：{0} 操作出现异常", rpEntity.incident_id);
                s_message.AppendFormat("申请单号：{0}操作失败,错误：{1}", rpEntity.incident_id, ex.Message);
                _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                goto last;
            }
            finally
            {
                //记日志
                LogUtil.Info(s_message.ToString());
            }
        last:
            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
            _XiangYingEntity.incident_id = rpEntity.incident_id;
            body = JsonConvert.SerializeObject(_XiangYingEntity);
            LogUtil.Info("chargeCollection方法返回" + S_IP + "结果：" + body);
            return _XiangYingEntity;
        }

        /// <summary>
        /// 用水性质变更
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="S_IP"></param>
        /// <returns></returns>
        public XiangYingEntity waterTypeChange(waterTypeChangeEntity rpEntity, string S_IP)
        {
            #region 定义变量
            string STR_CURRENT_COMPANY = ConfigurationManager.AppSettings["CURRENT_COMPANY"];
            int i_code = 0;
            bool b_isGood = true;
            string s_incident_type = "34";//此处为incident_type
            string s_result = string.Empty;//记录操作结果
            string body = "";
            StringBuilder s_message = new StringBuilder();
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_SHOULIXX _outWTB_SHOULIXX = new WTB_SHOULIXX();
            XiangYingEntity _XiangYingEntity = new XiangYingEntity();

            #endregion

            try
            {
                #region 记录参数
                //s_message.Append(_BusinessLogsticBase.GetParameterByMethod(i_WsNo, rpEntity));
                body = JsonConvert.SerializeObject(rpEntity);
                LogUtil.Info("waterTypeChange方法接收" + S_IP + "请求：" + body);
                #endregion

                #region 验证参数
                if (string.IsNullOrEmpty(rpEntity.incident_id)) { i_code = 11; s_result = "申请单唯一ID" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.source)) { i_code = 11; s_result = "提交渠道" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.apply_no)) { i_code = 11; s_result = "统一审批编码" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.applicant)) { i_code = 11; s_result = "申请人" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.appdate)) { i_code = 11; s_result = "申请时间" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.cert_type)) { i_code = 11; s_result = "申请人证件类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.cert_number)) { i_code = 11; s_result = "申请人证件号码" + s_suffix_notEmpty; goto last; }
                //if (string.IsNullOrEmpty(rpEntity.company_name)) { i_code = 11; s_result = "企业名称" + s_suffix_notEmpty; goto last; }
                //if (string.IsNullOrEmpty(rpEntity.company_type)) { i_code = 11; s_result = "企业类型" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.nsrsbh)) { i_code = 11; s_result = "纳税人识别号" + s_suffix_notEmpty; goto last; }
                //if (string.IsNullOrEmpty(rpEntity.email)) { i_code = 11; s_result = "电子邮箱" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.card_id)) { i_code = 11; s_result = "销根号/账户编号/用户号" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.address)) { i_code = 11; s_result = "用水地址" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.waterType)) { i_code = 11; s_result = "企业用水性质" + s_suffix_notEmpty; goto last; }
                if (string.IsNullOrEmpty(rpEntity.contact_num)) { i_code = 11; s_result = "联系人电话" + s_suffix_notEmpty; goto last; }



                //验证列表
                if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                {
                    b_isGood = new BusinessLogsticBase().ValidateCertList(rpEntity.CertList, out s_result);
                    if (!b_isGood) { i_code = 11; goto last; }
                }

                #endregion

                #region 验证该INCIDENT_ID记录是否已存在
                b_isGood = _BusinessLogsticBase.IsIncident_IDExist(rpEntity.incident_id);
                if (!b_isGood)
                {
                    i_code = 9;
                    s_result = string.Format("申请单号:{0}已存在", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0}已存在", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                #endregion
                _BusinessLogsticBase.CreatewaterTypeChangeEntity(rpEntity, out _outWTB_YEWUZB, out _outWTB_SHOULIXX);


                ResultEntity _result = searchWaterUserInfo(rpEntity.card_id, s_incident_type, S_IP, "0");//queryInvoice(_queryInvoiceEntity, S_IP);//再次调用验接口
                b_isGood = _result.isSuccess;
                if (!b_isGood)
                {
                    i_code = Convert.ToInt32(_result.errCode);
                    s_result = string.Format("申请单号:{0} 操作出现异常 {1}", rpEntity.incident_id, _result.message);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }

                #region 写入数据库
                //写入数据库主表
                b_isGood = _BusinessLogsticBase.IsMainInsGoodByID(_outWTB_YEWUZB);
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入子表
                b_isGood = _BusinessLogsticBase.IsChildInsGoodByResult(_outWTB_SHOULIXX, s_incident_type);
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_SHOULIXX表新增失败", rpEntity.incident_id);
                    _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入证件列表
                if (b_isGood)
                {
                    if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                    {
                        b_isGood = _BusinessLogsticBase.IsInsertCertListGood(rpEntity.CertList, _outWTB_YEWUZB);
                        if (!b_isGood)
                        {
                            i_code = 12;
                            s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 证件列表数和成功写入WTB_WENJIANXX表记录数不符", rpEntity.incident_id);
                            _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            goto last;
                        }
                        else
                        {
                            i_code = 200;
                            s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                            #region 不用逻辑
                            //if (STR_CURRENT_COMPANY == "PDWLY" || STR_CURRENT_COMPANY == "TRUE")//判断当前公司是否为威立雅
                            //{
                            //    string strParms = "";

                            //    strParms += rpEntity.user_name + ";";//V_USERNAME          VARCHAR2,
                            //    strParms += rpEntity.card_id + ";";//V_CID               VARCHAR2,
                            //    strParms += rpEntity.shw_address + ";";//v_shw_address       VARCHAR2,
                            //    strParms += rpEntity.nsrsbh + ";";//V_nsrsbh            VARCHAR2,
                            //    strParms += rpEntity.bill_month + ";";//V_bill_month        VARCHAR2,
                            //    strParms += rpEntity.money + ";";//V_money             NUMBER,
                            //    strParms += rpEntity.email + ";";//v_email             VARCHAR2,
                            //    strParms += rpEntity.contact_number + ";";//v_contact_number    VARCHAR2,
                            //    strParms += "一网通办" + ";";//V_CAOZUOR           VARCHAR2,
                            //    strParms += rpEntity.apply_no + ";";//V_YEWUBH            VARCHAR2,
                            //    strParms += rpEntity.incident_id + "";//v_incident_id         VARCHAR2,
                            //    DataTable dt_bgxx = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "INSERT;WTB_DZFAPIAOZDADD;" + strParms, "").Tables[0];//KEHUXXBG("2", rpEntity.card_id, kehulx, zhengjianlx, "", "", email, rpEntity.applicant, dianhua, shouji, "一网通办", rpEntity.incident_id, null);
                            //    if (dt_bgxx.Rows[0][0].ToString() != "00|")
                            //    {
                            //        i_code = 12;

                            //        s_message.Clear();
                            //        s_message.AppendFormat("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                            //        s_result = string.Format("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                            //        _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                            //        _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            //        goto last;
                            //    }
                            //    else
                            //    {
                            //        VatIvoService.VatIvoServiceClient vat = new VatIvoService.VatIvoServiceClient();
                            //        b_isGood = vat.QueryXml(rpEntity.card_id, rpEntity.user_name, rpEntity.shw_address, Convert.ToInt32(rpEntity.bill_month.Substring(0, 4)), Convert.ToInt32(rpEntity.bill_month.Substring(4, 2)), Convert.ToDecimal(rpEntity.money), rpEntity.nsrsbh, rpEntity.contact_number, rpEntity.email, "一网通办", 1, out s_result);
                            //        if (!b_isGood)
                            //        {
                            //            i_code = 12;
                            //            s_message.Clear();
                            //            //s_result = string.Format("申请单号:{0} 办理失败", rpEntity.incident_id);
                            //            s_message.AppendFormat("申请单号:{0} 办理失败{1}", rpEntity.incident_id, s_result);
                            //            s_result = string.Format("申请单号:{0} 办理失败{1}", rpEntity.incident_id, s_result);
                            //            _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                            //            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            //            goto last;
                            //        }
                            //    }
                            //}
                            #endregion
                        }
                    }
                    else
                    {
                        i_code = 200;
                        s_message.Clear();
                        s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                        s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                        #region 不用逻辑
                        //if (STR_CURRENT_COMPANY == "PDWLY" || STR_CURRENT_COMPANY == "TRUE")//判断当前公司是否为威立雅
                        //{
                        //    string strParms = "";
                        //    strParms += rpEntity.user_name + ";";//V_USERNAME          VARCHAR2,
                        //    strParms += rpEntity.card_id + ";";//V_CID               VARCHAR2,
                        //    strParms += rpEntity.shw_address + ";";//v_shw_address       VARCHAR2,
                        //    strParms += rpEntity.nsrsbh + ";";//V_nsrsbh            VARCHAR2,
                        //    strParms += rpEntity.bill_month + ";";//V_bill_month        VARCHAR2,
                        //    strParms += rpEntity.money + ";";//V_money             NUMBER,
                        //    strParms += rpEntity.email + ";";//v_email             VARCHAR2,
                        //    strParms += rpEntity.contact_number + ";";//v_contact_number    VARCHAR2,
                        //    strParms += "一网通办" + ";";//V_CAOZUOR           VARCHAR2,
                        //    strParms += rpEntity.apply_no + ";";//V_YEWUBH            VARCHAR2,
                        //    strParms += rpEntity.incident_id + "";//v_incident_id         VARCHAR2,

                        //    DataTable dt_bgxx = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "INSERT;WTB_DZFAPIAOZDADD;" + strParms, "").Tables[0];//KEHUXXBG("2", rpEntity.card_id, kehulx, zhengjianlx, "", "", email, rpEntity.applicant, dianhua, shouji, "一网通办", rpEntity.incident_id, null);
                        //    if (dt_bgxx.Rows[0][0].ToString() != "00|")
                        //    {
                        //        i_code = 12;
                        //        //s_result = string.Format("申请单号:{0} 办理失败", rpEntity.incident_id);
                        //        //s_message.AppendFormat("申请单号:{0} 办理失败", rpEntity.incident_id);

                        //        s_message.Clear();
                        //        s_message.AppendFormat("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                        //        s_result = string.Format("申请单号:{0} 办理失败原因：{1}", rpEntity.incident_id, dt_bgxx.Rows[0][0].ToString().Split('|')[1]);
                        //        _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                        //        _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                        //        goto last;
                        //    }
                        //    else
                        //    {
                        //        VatIvoService.VatIvoServiceClient vat = new VatIvoService.VatIvoServiceClient();
                        //        b_isGood = vat.QueryXml(rpEntity.card_id, rpEntity.user_name, rpEntity.shw_address, Convert.ToInt32(rpEntity.bill_month.Substring(0, 4)), Convert.ToInt32(rpEntity.bill_month.Substring(4, 2)), Convert.ToDecimal(rpEntity.money), rpEntity.nsrsbh, rpEntity.contact_number, rpEntity.email, "一网通办", 1, out s_result);
                        //        if (!b_isGood)
                        //        {
                        //            i_code = 12;
                        //            //s_result = string.Format("申请单号:{0} 办理失败", rpEntity.incident_id);
                        //            s_message.Clear();
                        //            s_message.AppendFormat("申请单号:{0} 办理失败{1}", rpEntity.incident_id, s_result);
                        //            s_result = string.Format("申请单号:{0} 办理失败{1}", rpEntity.incident_id, s_result);
                        //            _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                        //            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                        //            goto last;
                        //        }

                        //    }
                        //}
                        #endregion
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                i_code = 12;
                s_message.Clear();
                s_result = string.Format("申请单号：{0} 操作出现异常", rpEntity.incident_id);
                s_message.AppendFormat("申请单号：{0}操作失败,错误：{1}", rpEntity.incident_id, ex.Message);
                _AccessDataBase.UPDWTB_YEWUZB(rpEntity.incident_id, -1, null);
                _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                goto last;
            }
            finally
            {
                //记日志
                LogUtil.Info(s_message.ToString());
            }
        last:
            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
            _XiangYingEntity.incident_id = rpEntity.incident_id;
            body = JsonConvert.SerializeObject(_XiangYingEntity);
            LogUtil.Info("waterTypeChange方法返回" + S_IP + "结果：" + body);
            return _XiangYingEntity;
        }

        /// <summary>
        /// 业务咨询表扬建议
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="S_IP"></param>
        /// <returns></returns>
        public XiangYingEntity adviceComplain(adviceComplainEntity rpEntity, string S_IP)
        {
            string STR_CURRENT_COMPANY = ConfigurationManager.AppSettings["CURRENT_COMPANY"];
            string body = JsonConvert.SerializeObject(rpEntity);
            #region 定义变量
            int i_WsNo = (int)Web_Service_Name.Repair;//接口名称在枚举中对应的编号
            int i_code = 0;
            bool b_isGood = true;
            string s_result = string.Empty;//记录操作结果
            string message = "";//水务之声接口返回json串
            StringBuilder s_message = new StringBuilder();//记录参数和操作结果&方法参数
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_BAOXIUXX _outWTB_BAOXIUXX = new WTB_BAOXIUXX();
            XiangYingEntity _XiangYingEntity = new XiangYingEntity();
            #endregion

            try
            {

                #region 记录参数
                LogUtil.Info("adviceComplain方法接收" + S_IP + "请求：" + body);

                #endregion
                if (STR_CURRENT_COMPANY == "PDWLY")//判断当前公司是否为威立雅
                {
                    string URL_BAOXIU_HOT = ConfigurationManager.AppSettings["URL_BAOXIU_HOT"];
                    string METHODNAME_HOT = ConfigurationManager.AppSettings["METHODNAME_HOTONE"];
                    rpEntity.repair_comment = rpEntity.fynr;
                    rpEntity.fynr = rpEntity.fylb;
                    rpEntity.fyly = "一网通办";
                    rpEntity.case_type_cd = "报修";
                    body = JsonConvert.SerializeObject(rpEntity);
                    LogUtil.Info("adviceComplain方法开始转发请求：" + body);
                    message = _BusinessLogsticBase.QueryPostWebService(URL_BAOXIU_HOT, METHODNAME_HOT, body);//调水务之声接口
                    LogUtil.Info("adviceComplain方法接收" + URL_BAOXIU_HOT + "响应：" + message);
                }

                #region 验证该INCIDENT_ID记录是否已存在
                ////b_isGood = _BusinessLogsticBase.IsIncident_IDExist(rpEntity.incident_id);
                ////if (!b_isGood)
                ////{
                ////    i_code = 500;
                ////    s_result = string.Format("申请单号:{0}已存在", rpEntity.incident_id);
                ////    s_message.AppendFormat("申请单号:{0}已存在", rpEntity.incident_id);
                ////    return _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                ////}
                #endregion

                _BusinessLogsticBase.CreateadviceComplainEntity(rpEntity, out _outWTB_YEWUZB, out _outWTB_BAOXIUXX);
                #region 写入数据库
                //写入数据库主表
                b_isGood = _BusinessLogsticBase.IsMainInsGoodByID(_outWTB_YEWUZB);
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_YEWUZB表新增失败", rpEntity.incident_id);
                    ////return _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入子表
                b_isGood = _BusinessLogsticBase.IsChildInsGoodByResult(_outWTB_BAOXIUXX, _outWTB_YEWUZB.BUSINESS_TYPE);////需修改成string 类型
                if (!b_isGood)
                {
                    i_code = 12;
                    s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                    s_message.AppendFormat("申请单号:{0} WTB_BAOXIUXX表新增失败", rpEntity.incident_id);
                    ////return _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                    goto last;
                }
                //写入证件列表
                if (b_isGood)
                {
                    if (rpEntity.CertList != null && rpEntity.CertList.Count > 0)
                    {
                        b_isGood = _BusinessLogsticBase.IsInsertCertListGood(rpEntity.CertList, _outWTB_YEWUZB);
                        if (!b_isGood)
                        {
                            i_code = 12;
                            s_result = string.Format("申请单号:{0} 操作出现异常", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 证件列表数和成功写入WTB_WENJIANXX表记录数不符", rpEntity.incident_id);
                            _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                            goto last;
                        }
                        else
                        {
                            i_code = 200;
                            s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                            s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                        }
                    }
                    else
                    {
                        i_code = 200;
                        s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                        s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                    }
                }
                //else
                //{
                //    i_code = 200;
                //    s_result = string.Format("申请单号:{0} 新增成功", rpEntity.incident_id);
                //    s_message.AppendFormat("申请单号:{0} 新增成功", rpEntity.incident_id);
                //}
                #endregion
            }
            catch (Exception ex)
            {
                i_code = 12;
                s_result = string.Format("申请单号：{0}操作出现异常", rpEntity.incident_id);
                s_message.AppendFormat("申请单号：{0}操作失败,错误：{1}", rpEntity.incident_id, ex.Message);
                ////return _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                _XiangYingEntity = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                goto last;
            }
            finally
            {

                //记日志
                LogUtil.Info(s_message.ToString());

            }
        last:
            if (STR_CURRENT_COMPANY == "PDWLY")//判断当前公司是否为威立雅
            {
                XiangYingEntity result = JsonConvert.DeserializeObject<XiangYingEntity>(message);
                LogUtil.Info("adviceComplain方法转发响应：" + message);
                return result;//_BusinessLogsticBase.GetXiangYingResult(i_code,s_result);
            }
            else
            {
                XiangYingEntity result = _BusinessLogsticBase.GetXiangYingResult(i_code, s_result);
                LogUtil.Info("adviceComplain方法响应：" + message);
                return result;
            }
        }

        /// <summary>
        /// 补产证
        /// </summary>
        /// <param name="incident_id"></param>
        /// <param name="body"></param>
        /// <param name="S_IP"></param>
        /// <returns></returns>
        public string getProductionCertificateFile(string incident_id,string body,string caozuor, string S_IP)
        {
            string strParms = "";
            if (String.IsNullOrEmpty(body))
            {
                strParms += incident_id + ";";
                strParms += "CZ" + ";";
                body = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "SELECT;WTB_GETBODYSTR;" + strParms, "").Tables[0].Rows[0]["BODYSTR"].ToString();
            }
            LogUtil.Info("getProductionCertificateFile:incident_id:{0},body:{1}", incident_id, body);
            try
            {
                string URL_CERT = ConfigurationManager.AppSettings["URL_CERT"];
                string METHODNAME_CERT = ConfigurationManager.AppSettings["METHODNAME_CERT"];
                string localfilename = @""+ConfigurationManager.AppSettings["LocalMediaFiles"] + "/" + incident_id + "/补产证" + incident_id + ".pdf";
                if (_BusinessLogsticBase.SavePDFStream(URL_CERT + METHODNAME_CERT, body, localfilename))
                {
                    if (_BusinessLogsticBase.UploadFile2CSMS("/" + incident_id, localfilename))
                    {
                        strParms = "";
                        strParms += incident_id + ";";
                        strParms += System.IO.Path.GetFileName(localfilename) + ";";
                        strParms += (@"//WTB/" + incident_id + "/" + System.IO.Path.GetFileName(localfilename)) + ";";
                        strParms += caozuor + ";";
                        _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "insert;WTB_ADDMEDIAFILES;" + strParms, "");
                    }
                    else
                    {
                        localfilename = "";
                    }
                }
                else
                {
                    localfilename = "";
                }
                return localfilename;
            }
            catch (Exception ex)
            {
                LogUtil.Info("getProductionCertificateFile异常："+ex.Message);
                return "";
            }
        }

        public string getFiles(string INCIDENT_ID,string filename )
        {
            FtpWeb _ftp_wtb = null;
            FtpWeb _ftp_csms = null;
            _ftp_wtb = new FtpWeb(ConfigurationManager.AppSettings["FTP_IP"], ConfigurationManager.AppSettings["FTP_PATH"], ConfigurationManager.AppSettings["FTP_ACCOUNT"], ConfigurationManager.AppSettings["FTP_PWD"]);
            LogUtil.Info(ConfigurationManager.AppSettings["FTP_IP"].ToString() + ";" + ConfigurationManager.AppSettings["FTP_PATH"] + ";" + ConfigurationManager.AppSettings["FTP_ACCOUNT"] + ConfigurationManager.AppSettings["FTP_PWD"]);
            //if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["FTP_IP"]))
            //{
            //    DataSet ds = Platform.Data.OracleHelper.ExecuteDataset(Platform.Configuration.ConfigHelper.BusinessConnString, CommandType.Text, "select * from s_settings where keyname like 'FTP%'");
            //    string _csms_FTPUrl = ds.Tables[0].Select("KEYNAME='FTPUrl'")[0]["CONFIGVALUE"].ToString();// Platform.Common.KeyValueHelper.GetValue("FTPUrl");
            //    string _CSMS_PATH = ConfigurationManager.AppSettings["CSMS_PATH"];
            //    string _csms_FTPUsername = ds.Tables[0].Select("KEYNAME='FTPUsername'")[0]["CONFIGVALUE"].ToString();// Platform.Common.KeyValueHelper.GetValue("FTPUsername");
            //    string _csms_FTPPassword = ds.Tables[0].Select("KEYNAME='FTPPassword'")[0]["CONFIGVALUE"].ToString();// Platform.Common.KeyValueHelper.GetValue("FTPPassword");
            //    _ftp_csms = new FtpWeb(_csms_FTPUrl, _CSMS_PATH, _csms_FTPUsername, _csms_FTPPassword);
            //}
            _ftp_wtb.ftpURI = _ftp_wtb.ftpURI + INCIDENT_ID + "/";
            _BusinessLogsticBase.getFiles(INCIDENT_ID, filename);
            return null;
        }
        public CheckEntity IsIncident_IDExistByType(string incident_id, string businessType, string S_IP)
        {
            LogUtil.Info("incidentIDSearch方法接收" + S_IP + "请求：" + incident_id + "," + businessType);
            CheckEntity checkEntity = new CheckEntity();
            bool b_isGood = _BusinessLogsticBase.IsIncident_IDExistByType(incident_id, businessType);
            if (!b_isGood)
            {
                checkEntity.isSuccess = true;
                checkEntity.code = 200;
                checkEntity.errCode = "";
                checkEntity.message = "";
                checkEntity.flag = true;
            }
            else
            {
                checkEntity.isSuccess = true;
                checkEntity.code = 200;
                checkEntity.errCode = "";
                checkEntity.message = "";
                checkEntity.flag = false;
            }
            return checkEntity;
        }
        public searchBillDataEntity searchBillByCardIdOrZdDate(string source, string card_id, string start_zd_date, string end_zd_date, string phonename, string phone, string card_type, string card_number, string validity_card, string S_IP)
        {
            searchBillDataEntity entity = new searchBillDataEntity();
            try
            {

                string strParms = "";
                LogUtil.Info("searchBillByCardIdOrZdDate方法接收" + S_IP + "请求：" + source + "," + card_id + "," + start_zd_date + "," + end_zd_date + "," + phonename + "," + phone + "," + card_type + "," + card_number + "," + validity_card);
                if (!String.IsNullOrEmpty(card_id) && !String.IsNullOrEmpty(start_zd_date) && !String.IsNullOrEmpty(end_zd_date))
                {
                    strParms += source + ";";
                    strParms += card_id + ";";
                    strParms += start_zd_date + ";";
                    strParms += end_zd_date + ";";
                    strParms += phonename + ";";
                    strParms += card_type + ";";
                    strParms += card_number + ";";
                    strParms += validity_card + ";";
                    DataTable dt = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "SELECT;CT_GETZHANGWUCL_Bill;" + strParms, "").Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        List<ctbillList> dataList = new List<ctbillList>();
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            ctbillList data = new ctbillList();
                            data.I_ZHANGDANN = dt.Rows[i]["I_ZHANGDANN"].ToString();
                            data.I_ZHANGDANY = dt.Rows[i]["I_ZHANGDANY"].ToString();
                            data.S_ZHANGDANTXM = dt.Rows[i]["S_ZHANGDANTXM"].ToString();
                            data.S_HM = dt.Rows[i]["S_HM"].ToString();
                            data.S_DZ = dt.Rows[i]["S_DZ"].ToString();
                            data.S_CH = dt.Rows[i]["S_CH"].ToString();
                            data.D_CHAOBIAORQ = dt.Rows[i]["D_CHAOBIAORQ"].ToString();
                            data.D_XIACICBRQ = dt.Rows[i]["D_XIACICBRQ"].ToString();
                            data.S_YONGSHUIXZ = dt.Rows[i]["S_YONGSHUIXZ"].ToString();
                            data.S_SSDM = dt.Rows[i]["S_SSDM"].ToString();
                            data.S_CHAOBIAOY = dt.Rows[i]["S_CHAOBIAOY"].ToString();
                            data.I_SHANGCICM = Convert.ToDouble(dt.Rows[i]["I_SHANGCICM"]);
                            data.I_BENCICM = Convert.ToDouble(dt.Rows[i]["I_BENCICM"].ToString());
                            data.I_KAIZHANGSL = Convert.ToDouble(dt.Rows[i]["I_KAIZHANGSL"].ToString());
                            data.N_YONGHSHUIJ = Convert.ToDouble(dt.Rows[i]["N_YONGHSHUIJ"].ToString());
                            data.N_SHUIFEI = Convert.ToDouble(dt.Rows[i]["N_SHUIFEI"].ToString());
                            data.I_PAISHUIL = Convert.ToDouble(dt.Rows[i]["I_PAISHUIL"].ToString());
                            data.N_PAISHUIZKL = Convert.ToDouble(dt.Rows[i]["N_PAISHUIZKL"].ToString());
                            data.N_PAISHUIJ = Convert.ToDouble(dt.Rows[i]["N_PAISHUIJ"].ToString());
                            data.N_PAISHUIF = Convert.ToDouble(dt.Rows[i]["N_PAISHUIF"].ToString());
                            data.S_ZHUANGTAIMC = dt.Rows[i]["S_ZHUANGTAIMC"].ToString();
                            data.S_ZHUANGTAIMC1 = dt.Rows[i]["S_ZHUANGTAIMC1"].ToString();
                            data.S_KOUFENBS = dt.Rows[i]["S_KOUFENBS"].ToString();
                            data.I_NIANLEIJ = Convert.ToDouble(dt.Rows[i]["I_NIANLEIJ"].ToString());
                            data.I_JISHUYSL1 = Convert.ToDouble(dt.Rows[i]["I_JISHUYSL1"].ToString());
                            data.N_JISHUYSJ1 = Convert.ToDouble(dt.Rows[i]["N_JISHUYSJ1"].ToString());
                            data.N_JISHUYSF1 = Convert.ToDouble(dt.Rows[i]["N_JISHUYSF1"].ToString());
                            data.I_JISHUYSL2 = Convert.ToDouble(dt.Rows[i]["I_JISHUYSL2"].ToString());
                            data.N_JISHUYSJ2 = Convert.ToDouble(dt.Rows[i]["N_JISHUYSJ2"].ToString());
                            data.N_JISHUYSF2 = Convert.ToDouble(dt.Rows[i]["N_JISHUYSF2"].ToString());
                            data.I_JISHUYSL3 = Convert.ToDouble(dt.Rows[i]["I_JISHUYSL3"].ToString());
                            data.N_JISHUYSJ3 = Convert.ToDouble(dt.Rows[i]["N_JISHUYSJ3"].ToString());
                            data.N_JISHUYSF3 = Convert.ToDouble(dt.Rows[i]["N_JISHUYSF3"].ToString());
                            data.N_BENCIYE = Convert.ToDouble(dt.Rows[i]["N_BENCIYE"].ToString());
                            data.N_SHISHOUJE = Convert.ToDouble(dt.Rows[i]["N_SHISHOUJE"].ToString());
                            data.S_SHANGCIJFQK = dt.Rows[i]["S_SHANGCIJFQK"].ToString();
                            data.S_JIAOFEIBZ = dt.Rows[i]["S_JIAOFEIBZ"].ToString();
                            data.D_JIAOFEIQX = dt.Rows[i]["D_JIAOFEIQX"].ToString();
                            data.S_BIAODAS = dt.Rows[i]["S_BIAODAS"].ToString();
                            data.I_YONGSHUIBL = Convert.ToDouble(dt.Rows[i]["I_YONGSHUIBL"].ToString());
                            data.S_TUOSHOUHTH = dt.Rows[i]["S_TUOSHOUHTH"].ToString();
                            data.S_JIETIMS = dt.Rows[i]["S_JIETIMS"].ToString();
                            data.S_ZHANGDANSDDZ = dt.Rows[i]["S_ZHANGDANSDDZ"].ToString();
                            data.JIADAN1 = dt.Rows[i]["JIADAN1"].ToString();
                            data.JIADAN2 = dt.Rows[i]["JIADAN2"].ToString();
                            data.JIADAN3 = dt.Rows[i]["JIADAN3"].ToString();
                            data.S_WEIYUEJTS = dt.Rows[i]["S_WEIYUEJTS"].ToString();
                            data.LAST_BAL = Convert.ToDouble(dt.Rows[i]["LAST_BAL"].ToString());
                            data.CUR_AMT = Convert.ToDouble(dt.Rows[i]["CUR_AMT"].ToString());
                            data.DRK_REMARK = dt.Rows[i]["DRK_REMARK"].ToString();
                            data.JIUBIAODM1 = dt.Rows[i]["JIUBIAODM1"].ToString();
                            data.JIUBIAODM2 = dt.Rows[i]["JIUBIAODM2"].ToString();
                            data.YULIU1 = dt.Rows[i]["YULIU1"].ToString();
                            data.YULIU2 = dt.Rows[i]["YULIU2"].ToString();
                            data.YULIU3 = dt.Rows[i]["YULIU3"].ToString();
                            data.WRITE_TIME = Convert.ToDateTime(dt.Rows[i]["WRITE_TIME"].ToString());
                            data.READ_TIME = Convert.ToDateTime(dt.Rows[i]["READ_TIME"].ToString());
                            data.FLAG = dt.Rows[i]["FLAG"].ToString();
                            data.FJLBZ = dt.Rows[i]["FJLBZ"].ToString();
                            data.N_RTE_SEQ = Convert.ToDouble(dt.Rows[i]["N_RTE_SEQ"].ToString());
                            data.DRK_MS = dt.Rows[i]["DRK_MS"].ToString();
                            data.DRK_YSL = Convert.ToDouble(dt.Rows[i]["DRK_YSL"].ToString());
                            data.DRK_YSJ = Convert.ToDouble(dt.Rows[i]["DRK_YSJ"].ToString());
                            data.DRK_YSF = Convert.ToDouble(dt.Rows[i]["DRK_YSF"].ToString());
                            data.REMARK = dt.Rows[i]["REMARK"].ToString();
                            dataList.Add(data);
                        }
                        entity.code = 200;
                        entity.message = "";
                        entity.dataList = dataList;
                        entity.isSuccess = true;
                    }
                }
                else
                {

                    entity.code = 500;
                    entity.message = " 请输入必要的查询条件";
                    entity.dataList = new List<ctbillList>();
                    entity.isSuccess = false;
                }

            }
            catch (Exception ex)
            {
                LogUtil.Info("searchBillByCardIdOrZdDate异常：" + ex.Message);
                entity.code = 500;
                entity.message = ex.Message;
                entity.dataList = new List<ctbillList>();
                entity.isSuccess = false;
            }

            return entity;
        }
        public string scanCertQrCode(scanCertQrCodeEntity data, string S_IP)
        {
            //            
            string newbody = JsonConvert.SerializeObject(data);
            string body = newbody.Replace("Operator", "operator");
            LogUtil.Info("scanCertQrCode方法接收" + S_IP + "请求：" + body);

            scanCertQrCodeReturnEntity entity = new scanCertQrCodeReturnEntity();


            string URL_LZSM_WTB = ConfigurationManager.AppSettings["URL_LZSM_WTB"];//亮证扫码url
            string Environment = ConfigurationManager.AppSettings["Environment"];


            string METHODNAME_LZSM_WTB = ConfigurationManager.AppSettings["METHODNAME_LZSM_WTB"];//亮证扫码url

            //接口返回参数
            string returndata = _BusinessLogsticBase.QueryPostWebServiceNEW(URL_LZSM_WTB, METHODNAME_LZSM_WTB, body);

            LogUtil.Info("scanCertQrCode方法返回" + S_IP + "返回参数：" + returndata);

            try
            {
                entity = JsonConvert.DeserializeObject<scanCertQrCodeReturnEntity>(returndata);
                if (entity.success)
                {
                    string strParms = "";
                    strParms += data.businessHallName + ";";
                    strParms += data.systemName + ";";
                    strParms += data.Operator + ";";
                    strParms += data.businessName + ";";
                    strParms += data.certQrCode + ";";
                    strParms += entity.data.certificateType + ";";
                    strParms += entity.data.certificateHolderName + ";";
                    strParms += entity.data.certificateHolderCode + ";";
                    strParms += entity.data.pdfSftpPath + ";";
                    ///获取成功

                    //返回主表编号
                    DataTable dt = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "insert;WTB_INS_SAOMAXX;" + strParms, "").Tables[0];
                    //定义写 入证件列表 记录条数的方法            
                    FtpWeb _ftp_wtb = null;
                    FtpWeb _ftp_csms = null;
                    AccessDataBase adBase = new AccessDataBase();
                    string[] strArray = entity.data.pdfSftpPath.Split('/');
                    string Filename = strArray[strArray.Count() - 1];
                    WTB_WENJIANXX _WTB_WENJIANXX = new WTB_WENJIANXX()
                    {
                        ID = 0,
                        INCIDENT_ID = "产证" + dt.Rows[0]["S_ZHUBIAOBH"].ToString(),
                        S_ZHUBIAOBH = dt.Rows[0]["S_ZHUBIAOBH"].ToString(),
                        CERT_SOURCE = "01",
                        CERT_TYPE = entity.data.certificateType,
                        CERT_NUMBER = entity.data.certificateHolderCode,
                        FILE_UUID = null,
                        FILENAME = Filename,
                        WEB_URI = null
                    };
                    adBase.InsertWTB_WENJIANXX(_WTB_WENJIANXX, null);
                    DataSet ds = Platform.Data.OracleHelper.ExecuteDataset(Platform.Configuration.ConfigHelper.BusinessConnString, CommandType.Text, "select * from s_settings where keyname like 'FTP%'");
                    string _csms_FTPUrl = ds.Tables[0].Select("KEYNAME='FTPUrl'")[0]["CONFIGVALUE"].ToString();// Platform.Common.KeyValueHelper.GetValue("FTPUrl");
                    //string _CSMS_PATH = ConfigurationManager.AppSettings["CSMS_PATH"];
                    string _csms_FTPUsername = ds.Tables[0].Select("KEYNAME='FTPUsername'")[0]["CONFIGVALUE"].ToString();// Platform.Common.KeyValueHelper.GetValue("FTPUsername");
                    string _csms_FTPPassword = ds.Tables[0].Select("KEYNAME='FTPPassword'")[0]["CONFIGVALUE"].ToString();// Platform.Common.KeyValueHelper.GetValue("FTPPassword");
                    _ftp_csms = new FtpWeb(_csms_FTPUrl, entity.data.pdfSftpPath.Replace("/" + Filename, "").Substring(1), _csms_FTPUsername, _csms_FTPPassword);
                    FtpWeb _ftp_csmsMake ;
                    _ftp_csmsMake=  new FtpWeb(_csms_FTPUrl, entity.data.pdfSftpPath.Replace("/" + Filename, "").Replace("/" + strArray[strArray.Count() - 2],"").Substring(1), _csms_FTPUsername, _csms_FTPPassword);
                    LogUtil.Info("DirectoryExist" + entity.data.pdfSftpPath.Replace("/" + Filename, "").Replace("/" + strArray[strArray.Count() - 2], "") + "返回参数：" + strArray[strArray.Count() - 2]);
                    if (!_ftp_csmsMake.DirectoryExist(strArray[strArray.Count() - 2].Split('.')[0]))
                    {
                        _ftp_csmsMake.MakeDir(strArray[strArray.Count() - 2].Split('.')[0]);
                    }
                    if (Environment == "TEST")
                    {
                        _ftp_wtb = new FtpWeb("10.9.6.30", entity.data.pdfSftpPath.Replace("/" + Filename, "").Substring(1), "sangaowkfzztest", "sg@wkf666vs");
                        LogUtil.Info("下载文件:" + ConfigurationManager.AppSettings["FTP_IP"] + ConfigurationManager.AppSettings["FTP_ACCOUNT"] + "|" + ConfigurationManager.AppSettings["FTP_PWD"] + "|" + entity.data.pdfSftpPath.Replace("/" + Filename, "").Substring(1) + "|" + Filename + "到本地。");
                        //LogUtil.Info("本地文件存放地址：" + ConfigurationManager.AppSettings["LocalMediaFiles"] + "\\ChanZheng" + "\\" + Filename);

                        _ftp_wtb.Download(ConfigurationManager.AppSettings["LocalMediaFiles"] + "\\" + "ChanZheng", Filename);

                        _ftp_csms.Upload(ConfigurationManager.AppSettings["LocalMediaFiles"] + "\\" + "ChanZheng" + "/" + Filename);
                    }
                    else
                    {
                        _ftp_wtb = new FtpWeb("10.9.6.30", entity.data.pdfSftpPath.Replace("/" + Filename, "").Substring(1), "sangaowkfzztest", "sg@wkf666vs");                       
                        Directory.CreateDirectory(ConfigurationManager.AppSettings["LocalMediaFiles"] + entity.data.pdfSftpPath);
                        LogUtil.Info("下载文件:" + ConfigurationManager.AppSettings["FTP_IP"] + "16022;" + ConfigurationManager.AppSettings["FTP_ACCOUNT"] + "|" + ConfigurationManager.AppSettings["FTP_PWD"] + entity.data.pdfSftpPath + "到本地。");
                        _ftp_wtb.SFTPOperation(ConfigurationManager.AppSettings["FTP_IP"], "16022", ConfigurationManager.AppSettings["FTP_ACCOUNT"], ConfigurationManager.AppSettings["FTP_PWD"]);
                        _ftp_wtb.DownloadSFTP(entity.data.pdfSftpPath, ConfigurationManager.AppSettings["LocalMediaFiles"] + "\\" + "ChanZheng", Filename);

                        LogUtil.Info("上传文件:" + entity.data.pdfSftpPath + "到CSMS服务器");
                        _ftp_csms.Upload(ConfigurationManager.AppSettings["LocalMediaFiles"] + "\\" + "ChanZheng" + "/" + Filename);
                    }
                    if (dt != null)
                    {
                        if (dt.Rows.Count > 0)
                        {
                            string strParms2 = "";
                            ///循环遍历List数据
                            foreach (HolderList list in entity.data.holderList)
                            {
                                strParms2 = dt.Rows[0]["S_ZHUBIAOBH"].ToString() + ";";
                                strParms2 += list.code + ";";
                                strParms2 += list.name + ";";
                                strParms2 += list.type + ";";
                                dt = _AccessDataBase.GetParamsDataSource("<PROCEDURE>", "insert;WTB_INS_SAOMAXXMX;" + strParms2, "").Tables[0];
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogUtil.Info("scanCertQrCode方法返回" + S_IP + "返回参数：" + ex.Message);
            }
            return returndata;

        }
        public string TestCreateFile(string filepath)
        {
            string[] strArray = filepath.Split('/');
            string Filename = strArray[strArray.Count() - 1];
            DataSet ds = Platform.Data.OracleHelper.ExecuteDataset(Platform.Configuration.ConfigHelper.BusinessConnString, CommandType.Text, "select * from s_settings where keyname like 'FTP%'");                   
            string _csms_FTPUrl = ds.Tables[0].Select("KEYNAME='FTPUrl'")[0]["CONFIGVALUE"].ToString();// Platform.Common.KeyValueHelper.GetValue("FTPUrl");
            //string _CSMS_PATH = ConfigurationManager.AppSettings["CSMS_PATH"];
            string _csms_FTPUsername = ds.Tables[0].Select("KEYNAME='FTPUsername'")[0]["CONFIGVALUE"].ToString();// Platform.Common.KeyValueHelper.GetValue("FTPUsername");
            string _csms_FTPPassword = ds.Tables[0].Select("KEYNAME='FTPPassword'")[0]["CONFIGVALUE"].ToString();// Platform.Common.KeyValueHelper.GetValue("FTPPassword");
            //_ftp_csms = new FtpWeb(_csms_FTPUrl, entity.data.pdfSftpPath.Replace("/" + Filename, "").Substring(1), _csms_FTPUsername, _csms_FTPPassword);
            FtpWeb _ftp_csmsMake;
            _ftp_csmsMake = new FtpWeb(_csms_FTPUrl, filepath.Replace("/" + Filename, "").Replace("/" + strArray[strArray.Count() - 2], "").Substring(1), _csms_FTPUsername, _csms_FTPPassword);
            LogUtil.Info("DirectoryExist" + filepath.Replace("/" + Filename, "").Replace("/" + strArray[strArray.Count() - 2], "") + "返回参数：" + strArray[strArray.Count() - 2]);
            if (!_ftp_csmsMake.DirectoryExist(strArray[strArray.Count() - 2].Split('.')[0]))
            {
                _ftp_csmsMake.MakeDir(strArray[strArray.Count() - 2].Split('.')[0]);
            }
            return filepath;
        }
        #region 热线公告
        /// <summary>
        /// base64转PDF
        /// </summary>
        /// <param name="base64">base64字符</param>
        /// <param name="filename">文件名</param>
        /// <param name="filenamePath">文件路径</param>
        /// <returns></returns>
        public string SaveDocument(string base64, string filenamePath, string filename)
        {
            try
            {

                //string path = "~/Upload/";
                string sFilePath = filenamePath;
                string sFileName = filename /*"123." + "pdf"*/;   //这里的imageFormat就是文件类型
                sFileName = sFilePath + "\\" + sFileName;
                //路径不存在，则创建路径
                if (!Directory.Exists(sFilePath))
                {
                    Directory.CreateDirectory(sFilePath);
                }
                //如果文件已经存在，则删除文件
                if (System.IO.File.Exists(sFileName))
                {
                    System.IO.File.Delete(sFileName);
                }
                //注意：文件直接转base64前面会带有“data:application/pdf;base64,”前缀，需要去掉。
                byte[] DocBytes = Convert.FromBase64String(base64);
                //文件流创建文件内容
                FileStream fs = new FileStream(sFileName, FileMode.CreateNew);
                BinaryWriter bw = new BinaryWriter(fs);
                bw.Write(DocBytes, 0, DocBytes.Length);
                bw.Close();
                fs.Close();
                return "1";
            }
            catch (Exception ex)
            {
                LogUtil.Error("SaveDocument生成发生异常：{0}", ex);
                return "error";
            }
        }
        public bool RXGGXZZZ(string V_Citem, string V_Ctitle, string V_Cnotes, string V_Ctzfw, string base64zifu, string FileNames, out string msg)
        {
            bool _result;
            try
            {
                msg = "";
                _result = true;

                string V_Cfujian = "";
                bool wjcgsb = true;
                string WJRESULT = "";
                if (!string.IsNullOrEmpty(FileNames))
                {
                    string Branchofficersult = "";
                    string srcPath = @"D:\RXGG";

                    string Filename = FileNames;
                    Branchofficersult = SaveDocument(base64zifu, srcPath, Filename);
                    //msg = "文件保存失败";
                    //_result = false;
                    //return _result;
                    if (Branchofficersult != "1")
                    {
                        msg = "文件保存失败";
                        _result = false;
                        return _result;
                    }
                    else
                    {
                        wjcgsb = UPLOADWJ(srcPath + @"\" + Filename, Filename, out WJRESULT);//附件上传的返回值
                        if (wjcgsb)
                        {
                            V_Cfujian = WJRESULT;
                        }
                        else
                        {
                            msg = WJRESULT;
                            _result = false;
                            return _result;
                        }

                    }
                }
                requestZZ requestZZXX = new requestZZ()
                {
                    Citem = V_Citem,
                    Cdler = "cszls1",
                    Cggdw = "浦东新区自来水",
                    Ctitle = V_Ctitle,
                    Cnotes = V_Cnotes,
                    Ctzfw = V_Ctzfw,
                    Cfujian = V_Cfujian,
                    ID = ""

                };
                string requestZZJSON = JsonConvert.SerializeObject(requestZZXX);
                LogUtil.Info("RXGGXZZZ请求的参数：{0}", requestZZJSON);
                string PostUrl = ConfigurationManager.AppSettings["RXGG_IP_ZZXZ"];//post请求   
                //string PostUrl = @"http://128.1.8.43:2023/api/AddBoard";
                string resultData = BusinessLogsticBase.PostJK(requestZZJSON, PostUrl);
                LogUtil.Info("RXGGXZZZ接收的参数：{0}", resultData);
                responseJG JSdates = JsonConvert.DeserializeObject<responseJG>(resultData);
                if (JSdates.Code != 0)
                {
                    msg = JSdates.Message;
                    _result = false;
                }
                else
                {
                    msg = JSdates.Message;//新增成功返回ID
                }

                return _result;
            }
            catch (Exception ex)
            {

                LogUtil.Info("RXGGXZZZ:{0}", ex.Message);
                msg = ex.Message;
                return false;
            }
        }
        public bool RXGGXGZZ(string V_Citem, string V_Ctitle, string V_Cnotes, string V_Ctzfw, string V_ID, string base64zifu, out string msg)
        {
            bool _result;

            try
            {
                string srcPath = @"D:\RXGG";
                DataSet ds = _AccessDataBase.QueryWJMC(V_ID);
                string V_Cfujian = "";//附件上传的返回值
                _result = true;
                if (ds.Tables[0].Rows.Count > 0)
                {
                    string Filename = ds.Tables[0].Rows[0]["S_WENJIANMC"].ToString();
                    msg = "";
                    bool wjcgsb = true;
                    string WJRESULT = "";
                    wjcgsb = UPLOADWJ(srcPath + @"\" + Filename, Filename, out WJRESULT);//附件上传的返回值
                    if (wjcgsb)
                    {
                        V_Cfujian = WJRESULT;
                    }
                    else
                    {
                        msg = WJRESULT;
                        _result = false;
                        return _result;
                    }
                }

                requestZZ requestZZXX = new requestZZ()
                {
                    Citem = V_Citem,
                    Cdler = "cszls1",
                    Cggdw = "浦东新区自来水",
                    Ctitle = V_Ctitle,
                    Cnotes = V_Cnotes,
                    Ctzfw = V_Ctzfw,
                    Cfujian = V_Cfujian,
                    ID = V_ID

                };

                string requestZZJSON = JsonConvert.SerializeObject(requestZZXX);
                LogUtil.Info("RXGGXGZZ请求的参数：{0}", requestZZJSON);
                //string PostUrl = @"http://128.1.8.43:2023/api/EditBoard";//post请求
                string PostUrl = ConfigurationManager.AppSettings["RXGG_IP_ZZXG"];//post请求  
                string resultData = BusinessLogsticBase.PostJK(requestZZJSON, PostUrl);
                LogUtil.Info("RXGGXGZZ接收的参数：{0}", resultData);
                responseJG JSdates = JsonConvert.DeserializeObject<responseJG>(resultData);
                if (JSdates.Code != 0)
                {
                    msg = JSdates.Message;
                    _result = false;
                }
                msg = JSdates.Message;
                return _result;
            }
            catch (Exception ex)
            {

                LogUtil.Info("RXGGXGZZ:{0}", ex.Message);
                msg = ex.Message;
                return false;
            }
        }
        public bool RXGGXZGC(string V_Tstype, string V_Tsbt, string V_Jhtssj, string V_Jhfssj, string V_Tsnr, string V_TsFW, string V_Caliber, string V_Station, out string msg)
        {

            bool _result;
            try
            {
                V_Station = "浦东新区自来水";
                msg = "";
                _result = true;
                requestGC requestGCXX = new requestGC()
                {
                    Tstype = V_Tstype,
                    Fbr = "cszls1",
                    Fbdw = "浦东新区自来水",
                    Tsbt = V_Tsbt,
                    Jhtssj = V_Jhtssj,
                    Jhfssj = V_Jhfssj,
                    Tsnr = V_Tsnr,
                    Yxuser = "cszls1",
                    TsFW = V_TsFW,
                    Caliber = V_Caliber,
                    Station = V_Station,
                    Id = "",
                    GSName = ""

                };
                string requestGCJSON = JsonConvert.SerializeObject(requestGCXX);
                LogUtil.Info("RXGGXZGC请求的参数：{0}", requestGCJSON);
                //string PostUrl = ConfigurationManager.AppSettings["RXGG_IP_REQUESTGG"];//post请求   
                //string PostUrl = @"http://128.1.8.43:2023/api/AddBoardTS";
                string PostUrl = ConfigurationManager.AppSettings["RXGG_IP_GCXZ"];//post请求  
                string resultData = BusinessLogsticBase.PostJK(requestGCJSON, PostUrl);
                LogUtil.Info("RXGGXZGC接收的参数：{0}", resultData);
                responseJG JSdates = JsonConvert.DeserializeObject<responseJG>(resultData);
                if (JSdates.Code != 0)
                {
                    msg = JSdates.Message;
                    _result = false;
                }
                msg = msg = JSdates.Message;
                return _result;
            }
            catch (Exception ex)
            {

                LogUtil.Info("RXGGXZGC:{0}", ex.Message);
                msg = ex.Message;
                return false;
            }
        }
        public bool RXGGXGGC(string V_Tstype, string V_Tsbt, string V_Jhtssj, string V_Jhfssj, string V_Tsnr, string V_TsFW, string V_Caliber, string V_Station, string V_Id, out string msg)
        {
            bool _result;
            try
            {
                msg = "";
                _result = true;
                V_Station = "浦东新区自来水";
                requestGC requestGCXX = new requestGC()
                {
                    Tstype = V_Tstype,
                    Fbr = "cszls1",
                    Fbdw = "浦东新区自来水",
                    Tsbt = V_Tsbt,
                    Jhtssj = V_Jhtssj,
                    Jhfssj = V_Jhfssj,
                    Tsnr = V_Tsnr,
                    Yxuser = "cszls1",
                    TsFW = V_TsFW,
                    Caliber = V_Caliber,
                    Station = V_Station,
                    Id = V_Id,
                    GSName = ""

                };
                string requestGCJSON = JsonConvert.SerializeObject(requestGCXX);
                LogUtil.Info("RXGGXGGC请求的参数：{0}", requestGCJSON);
                //string PostUrl = @"http://128.1.8.43:2023/api/EditBoardTS";
                // string PostUrl = ConfigurationManager.AppSettings["RXGG_IP_REQUESTXGGG"];//post请求  
                string PostUrl = ConfigurationManager.AppSettings["RXGG_IP_GCXG"];//post请求  
                string resultData = BusinessLogsticBase.PostJK(requestGCJSON, PostUrl);
                LogUtil.Info("RXGGXGGC接收的参数：{0}", resultData);
                responseJG JSdates = JsonConvert.DeserializeObject<responseJG>(resultData);
                if (JSdates.Code != 0)
                {
                    msg = JSdates.Message;
                    _result = false;
                }
                msg = JSdates.Message;
                return _result;
            }
            catch (Exception ex)
            {

                LogUtil.Info("RXGGXGGC:{0}", ex.Message);
                msg = ex.Message;
                return false;
            }
        }
        public bool RXSCGZXX(int V_Id, out string msg)
        {
            bool _result;
            try
            {
                msg = "";
                _result = true;
                responseGZSC requestGCXX = new responseGZSC()
                {
                    Id = V_Id,
                    Fbr = "cszls1",
                    Fbdw = "浦东新区自来水"
                };
                string requestGCJSON = JsonConvert.SerializeObject(requestGCXX);
                LogUtil.Info("RXSCGZXX请求的参数：{0}", requestGCJSON);
                //string PostUrl = ConfigurationManager.AppSettings["RXGG_IP_REQUESTXGGG"];//post请求   
                // string PostUrl = @"http://128.1.8.43:2023/api/DelBoard";
                string PostUrl = ConfigurationManager.AppSettings["RXGG_IP_ZZSC"];//post请求  
                string resultData = PostJK("DELETE", requestGCJSON, PostUrl); //BusinessLogsticBase.PostJK(requestGCJSON, PostUrl);
                LogUtil.Info("RXSCGZXX接收的参数：{0}", resultData);
                responseJG JSdates = JsonConvert.DeserializeObject<responseJG>(resultData);
                if (JSdates.Code != 0)
                {
                    msg = JSdates.Message;
                    _result = false;
                }
                msg = JSdates.Message;
                return _result;
            }
            catch (Exception ex)
            {

                LogUtil.Info("RXSCGZXX:{0}", ex.Message);
                msg = ex.Message;
                return false;
            }
        }
        public bool RXSCGCXX(int V_Id, out string msg)
        {
            bool _result;
            try
            {
                msg = "";
                _result = true;
                responseGZSC requestGCXX = new responseGZSC()
                {
                    Id = V_Id,
                    Fbr = "cszls1",
                    Fbdw = "浦东新区自来水"
                };
                string requestGCJSON = JsonConvert.SerializeObject(requestGCXX);
                LogUtil.Info("RXSCGCXX请求的参数：{0}", requestGCJSON);
                // string PostUrl = ConfigurationManager.AppSettings["RXGG_IP_REQUESTXGGG"];//post请求   
                //string PostUrl = @"http://128.1.8.43:2023/api/DelBoardTS";
                string PostUrl = ConfigurationManager.AppSettings["RXGG_IP_GCSC"];//post请求  
                string resultData = PostJK("DELETE", requestGCJSON, PostUrl);
                LogUtil.Info("RXSCGCXX接收的参数：{0}", resultData);
                responseJG JSdates = JsonConvert.DeserializeObject<responseJG>(resultData);
                if (JSdates.Code != 0)
                {
                    msg = JSdates.Message;
                    _result = false;
                }
                msg = JSdates.Message;
                return _result;
            }
            catch (Exception ex)
            {

                LogUtil.Info("RXSCGCXX:{0}", ex.Message);
                msg = ex.Message;
                return false;
            }
        }
        #region 文件上传
        public bool UPLOADWJ(string wjlj, string wjmc, out string message)
        {
            message = "";
            return true ;
            //using (HttpClient client = new HttpClient())
            //{
            //    var content = new MultipartFormDataContent();
            //    //添加字符串参数，参数名为qq
            //    //content.Add(new StringContent("123456"), "qq");
            //    // string path = HttpContext.Current.Server.MapPath("~/LSTP/123.jpg");
            //    string path = wjlj;
            //    FileInfo file = new FileInfo(path);
            //    long size = file.Length;
            //    if (size < 1048576)
            //    {
            //        int index = wjmc.LastIndexOf('.');
            //        string wenjianmchz = wjmc.Substring(index + 1);
            //        Random rd = new Random();
            //        int i = rd.Next();
            //        string scwenjianmc = DateTime.Now.ToString("yyyyMMddhhmmss") + i.ToString();
            //        //添加文件参数，参数名为files，文件名为123.png
            //        content.Add(new ByteArrayContent(System.IO.File.ReadAllBytes(path)), "file", scwenjianmc + "." + wenjianmchz);
            //        LogUtil.Info("UPLOADWJ原文件名:" + wjmc + "修改为{0}", scwenjianmc + "." + wenjianmchz);
            //        // var requestUri = "http://128.1.8.43:2023/api/PostFile";
            //        //var requestUri = "https://localhost:44392/api/Home/ttt";
            //        string requestUri = ConfigurationManager.AppSettings["RXGG_IP_WJSC"];//post请求  
            //        var result = client.PostAsync(requestUri, content).Result.Content.ReadAsStringAsync().Result;
            //        //{"Code":0,"Message":"197876ca-1036-45a7-bdbf-35ace496c41f.jpg"}
            //        LogUtil.Info("RXZZUPLOADWJ返回的参数：{0}", result);
            //        responseJG JSdates = JsonConvert.DeserializeObject<responseJG>(result);
            //        if (JSdates.Code == 0)
            //        {
            //            message = JSdates.Message;
            //            return true;
            //        }
            //        else
            //        {
            //            message = JSdates.Message;
            //            return false;
            //        }
            //        //Console.WriteLine(result);
            //    }
            //    else
            //    {
            //        message = "上传文件大小请小于1M";
            //        return false;
            //    }
            //    //1048576


            //}

        }
        #endregion
        #region 接口请求方法(Post)
        /// <summary>
        /// http Post请求
        /// </summary>
        /// <param name="parameterData">参数</param>
        /// <param name="serviceUrl">访问地址</param>
        /// <param name="ContentType">默认 application/json , application/x-www-form-urlencoded,multipart/form-data,raw,binary </param>
        /// <param name="Accept">默认application/json</param>
        /// <returns></returns>
        public static string PostJK(string QQFS, string parameterData, string serviceUrl, string ContentType = "application/json", string Accept = "application/json")
        {

            //先根据用户请求的uri构造请求地址
            //string serviceUrl = string.Format("{0}/{1}", this.BaseUri, uri);

            //创建Web访问对象
            HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(serviceUrl);
            //把用户传过来的数据转成“UTF-8”的字节流
            byte[] buf = System.Text.Encoding.GetEncoding("UTF-8").GetBytes(parameterData);

            // myRequest.Method = "POST";
            //myRequest.Method = "DELETE";
            myRequest.Method = QQFS;
            //myRequest.Accept = "application/json";
            //myRequest.ContentType = "application/json";  // //Content-Type: application/x-www-form-urlencoded 
            myRequest.AutomaticDecompression = DecompressionMethods.GZip;
            myRequest.Accept = Accept;
            //myRequest.ContentType = ContentType;
            myRequest.ContentType = "application/json; charset=UTF-8";
            myRequest.ContentLength = buf.Length;
            myRequest.MaximumAutomaticRedirections = 1;
            myRequest.AllowAutoRedirect = true;

            //myRequest.Headers.Add("content-type", "application/json");
            //myRequest.Headers.Add("accept-encoding", "gzip");
            //myRequest.Headers.Add("accept-charset", "utf-8");

            //发送请求
            Stream stream = myRequest.GetRequestStream();
            stream.Write(buf, 0, buf.Length);
            stream.Close();

            //通过Web访问对象获取响应内容
            HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
            //通过响应内容流创建StreamReader对象，因为StreamReader更高级更快
            StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
            //string returnXml = HttpUtility.UrlDecode(reader.ReadToEnd());//如果有编码问题就用这个方法
            string returnData = reader.ReadToEnd();//利用StreamReader就可以从响应内容从头读到尾

            reader.Close();
            myResponse.Close();

            return returnData;
        }
        #endregion
        #region 类
        [Serializable]
        public class requestZZ
        {
            /// <summary>
            /// 公告类型（只可传递：公告、备案）
            /// </summary>
            public string Citem { get; set; }
            /// <summary>
            /// 发布人（川沙传递固定值：cszls1）
            /// </summary>
            public string Cdler { get; set; }
            /// <summary>
            /// 发布单位（川沙传递固定值：浦东新区自来水）
            /// </summary>
            public string Cggdw { get; set; }
            /// <summary>
            /// 标题（最大长度100字符）
            /// </summary>
            public string Ctitle { get; set; }
            /// <summary>
            /// 内容（最大长度2000字符）
            /// </summary>
            public string Cnotes { get; set; }
            /// <summary>
            /// 通知范围（可为空，最大长度50字符）
            /// </summary>
            public string Ctzfw { get; set; }
            /// <summary>
            /// 附件（可为空，先调用上传文件接口，将返回的message填充至该字段提交）
            /// </summary>
            public string Cfujian { get; set; }
            /// <summary>
            /// 标识 可不传递，修改传递对应的值
            /// </summary>
            public string ID { get; set; }
        }
        [Serializable]
        public class requestGC
        {
            /// <summary>
            /// 停水类型 （只可传递：计划停水、抢修停水、清洗水箱）
            /// </summary>
            public string Tstype { get; set; }
            /// <summary>
            /// 发布人（川沙传递固定值：cszls1）
            /// </summary>
            public string Fbr { get; set; }
            /// <summary>
            /// 发布单位（川沙传递固定值：浦东新区自来水）
            /// </summary>
            public string Fbdw { get; set; }
            /// <summary>
            /// 标题（最大长度50字符）
            /// </summary>
            public string Tsbt { get; set; }
            /// <summary>
            /// 计划停水时间（格式：YYYY‑MM‑dd HH:mm）
            /// </summary>
            public string Jhtssj { get; set; }
            /// <summary>
            /// 计划复水时间（格式：YYYY‑MM‑dd HH:mm）
            /// </summary>
            public string Jhfssj { get; set; }
            /// <summary>
            /// 停水内容（最大长度2000字符）
            /// </summary>
            public string Tsnr { get; set; }
            /// <summary>
            /// 操作人（川沙传递固定值：cszls1）
            /// </summary>
            public string Yxuser { get; set; }
            /// <summary>
            /// 范围（最大长度1000字符）
            /// </summary>
            public string TsFW { get; set; }
            /// <summary>
            /// 口径（最大长度50字符）
            /// </summary>
            public string Caliber { get; set; }
            /// <summary>
            /// 区域所属管理所（最大长度50字符）
            /// </summary>
            public string Station { get; set; }
            /// <summary>
            /// 标识（新增时可不传递，修改时传递标识ID用于更新）
            /// </summary>
            public string Id { get; set; }
            /// <summary>
            /// 公司名称（可为空，最大长度50字符，川沙之前均为空，更新时不传递）
            /// </summary>
            public string GSName { get; set; }
        }
        //返回结果
        [Serializable]
        public class responseGZSC
        {
            public int Id { get; set; }
            public string Fbr { get; set; }
            public string Fbdw { get; set; }
        }
        //返回结果
        [Serializable]
        public class responseJG
        {
            /// <summary>
            /// 返回码 0=成功 其他失败
            /// </summary>
            public int Code { get; set; }
            /// <summary>
            /// 返回描述信息。新增时返回标识ID；失败时返回错误原因
            /// </summary>
            public string Message { get; set; }
        }
        #endregion
        #endregion
        #region 川沙客服单上传文件
        public bool CSKHDSCWJ(string SerialNumber, string base64zifu, string FileNames, out string msg)
        {
            bool _result;
            try
            {
                string lujin = base64zifu.TrimStart();
                LogUtil.Info("CSKHDSCWJ文件路径：:" + base64zifu);
                msg = "";
                _result = true;

                string V_Cfujian = "";
                bool wjcgsb = true;
                string WJRESULT = "";
                if (!string.IsNullOrEmpty(FileNames))
                {
                    string srcPath = @"D:\CSKFWJ";

                    string Filename = FileNames;
                    FtpWeb _ftp_wtb = null;
                    if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["CSMSFTP_IP"]))
                        _ftp_wtb = new FtpWeb(ConfigurationManager.AppSettings["CSMSFTP_IP"], lujin, ConfigurationManager.AppSettings["CSMSFTP_ACCOUNT"], ConfigurationManager.AppSettings["CSMSFTP_PWD"]);
                    _ftp_wtb.Download(srcPath, FileNames);
                    //    _ftp_wtb = new FtpWeb("43.142.60.249", base64zifu, "xsy", "123456");
                    //_ftp_wtb.Download(srcPath, FileNames);
                    LogUtil.Info("下载文件:" + ConfigurationManager.AppSettings["CSMSFTP_IP"] + "16022;" + ConfigurationManager.AppSettings["CSMSFTP_ACCOUNT"] + "|" + ConfigurationManager.AppSettings["CSMSFTP_PWD"] + _ftp_wtb.ftpURI + FileNames + "到本地。");
                    //string Branchofficersult = "";

                    // Branchofficersult = SaveDocument(base64zifu, srcPath, Filename);
                    //msg = "文件保存失败";
                    //_result = false;
                    //return _result;
                    //if (Branchofficersult != "1")
                    //{
                    //    msg = "文件保存失败";
                    //    _result = false;
                    //    return _result;
                    //}
                    //else
                    //{
                    string requestUri = ConfigurationManager.AppSettings["RXGG_IP_DWJSC"] + "?SerialNumber=" + SerialNumber;//post请求  
                    LogUtil.Info("CSKHDSCWJ请求路径：" + requestUri);
                    wjcgsb = DKFUPLOADWJ(srcPath + @"\" + Filename, Filename, requestUri, out WJRESULT);//附件上传的返回值
                    LogUtil.Info("CSKHDSCWJ返回信息：" + WJRESULT);
                    if (wjcgsb)
                    {
                        V_Cfujian = WJRESULT;
                    }
                    else
                    {
                        msg = WJRESULT;
                        _result = false;
                        return _result;
                    }


                    //}
                }
                return _result;
            }
            catch (Exception ex)
            {

                LogUtil.Info("CSKHDSCWJ:{0}", ex.Message);
                msg = ex.Message;
                return false;
            }
        }
        #region 文件上传

        //public bool DKFUPLOADWJ(string wjlj, string wjmc, string URL, out string message)
        //{
        //    message = string.Empty; // 初始化返回消息

        //    try
        //    {
        //        string path = wjlj;
        //        FileInfo file = new FileInfo(path);
        //        long size = file.Length;

        //        // 如果需要文件大小检查，取消注释以下代码：
        //        // if (size < 1048576)
        //        // {
        //        int index = wjmc.LastIndexOf('.');
        //        string wenjianmchz = wjmc.Substring(index + 1);
        //        Random rd = new Random();
        //        int i = rd.Next();
        //        string scwenjianmc = DateTime.Now.ToString("yyyyMMddhhmmss") + i.ToString();

        //        // 读取文件数据
        //        byte[] fileBytes = File.ReadAllBytes(path);

        //        // 创建HttpWebRequest
        //        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
        //        request.Method = "POST";
        //        request.ContentType = "multipart/form-data; boundary=------------------------boundarystring";

        //        using (Stream requestStream = request.GetRequestStream())
        //        {
        //            // 添加文件的头部
        //            string header = "\r\n--------------------------boundarystring\r\n";
        //            string filePartHeader = "Content-Disposition: form-data; name=\"file\"; filename=\"" + scwenjianmc + "." + wenjianmchz + "\"\r\n" +
        //                                    "Content-Type: application/octet-stream\r\n\r\n";
        //            byte[] headerBytes = Encoding.UTF8.GetBytes(header + filePartHeader);
        //            requestStream.Write(headerBytes, 0, headerBytes.Length);

        //            // 写入文件内容
        //            requestStream.Write(fileBytes, 0, fileBytes.Length);

        //            // 添加请求的结束标志
        //            byte[] footer = Encoding.UTF8.GetBytes("\r\n------------------------boundarystring--\r\n");
        //            requestStream.Write(footer, 0, footer.Length);
        //        }

        //        // 获取响应并读取结果
        //        using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
        //        {
        //            using (StreamReader reader = new StreamReader(response.GetResponseStream()))
        //            {
        //                string result = reader.ReadToEnd();
        //                LogUtil.Info("DKFUPLOADWJ返回的参数：{0}", result);

        //                // 解析返回的JSON数据
        //                responseJG JSdates = JsonConvert.DeserializeObject<responseJG>(result);

        //                if (JSdates.Code == 0)
        //                {
        //                    message = JSdates.Message;
        //                    return true;
        //                }
        //                else
        //                {
        //                    message = JSdates.Message;
        //                    return false;
        //                }
        //            }
        //        }
        //        // }
        //        // else
        //        // {
        //        //     message = "上传文件大小请小于1M";
        //        //     return false;
        //        // }
        //    }
        //    catch (Exception ex)
        //    {
        //        message = "上传文件失败: " + ex.Message;
        //        return false;
        //    }
        //}


        public bool DKFUPLOADWJ(string wjlj, string wjmc, string URL, out string message)
        { 
            using (HttpClient client = new HttpClient())
            {
                var content = new MultipartFormDataContent();
                string path = wjlj;
                FileInfo file = new FileInfo(path);
                long size = file.Length;
                //if (size < 1048576)
                //{
                int index = wjmc.LastIndexOf('.');
                string wenjianmchz = wjmc.Substring(index + 1);
                Random rd = new Random();
                int i = rd.Next();
                string scwenjianmc = DateTime.Now.ToString("yyyyMMddhhmmss") + i.ToString();
                //添加文件参数，参数名为files，文件名为123.png
                content.Add(new ByteArrayContent(System.IO.File.ReadAllBytes(path)), "file", scwenjianmc + "." + wenjianmchz);
                LogUtil.Info("DKFUPLOADWJ原文件名:" + wjmc + "修改为{0}", scwenjianmc + "." + wenjianmchz);
                string requestUri = URL;//post请求  
                var result = client.PostAsync(requestUri, content).Result.Content.ReadAsStringAsync().Result;
                //{"Code":0,"Message":"197876ca-1036-45a7-bdbf-35ace496c41f.jpg"}
                LogUtil.Info("DKFUPLOADWJ返回的参数：{0}", result);
                responseJG JSdates = JsonConvert.DeserializeObject<responseJG>(result);
                if (JSdates.Code == 0)
                {
                    message = JSdates.Message;
                    return true;
                }
                else
                {
                    message = JSdates.Message;
                    return false;
                }
                //Console.WriteLine(result);
                //}
                //else
                //{
                //    message = "上传文件大小请小于1M";
                //    return false;
                //}
                //1048576


            }

        }
        public bool CSKHDSCWJN(string SerialNumber, string base64zifu, string FileNames)
        {
            bool _result;
            try
            {
                string lujin = base64zifu.TrimStart();
                LogUtil.Info("CSKHDSCWJN文件路径：:" + base64zifu);

                _result = true;

                string V_Cfujian = "";
                bool wjcgsb = true;
                string WJRESULT = "";
                if (!string.IsNullOrEmpty(FileNames))
                {
                    string srcPath = @"D:\CSKFWJ";

                    string Filename = FileNames;
                    FtpWeb _ftp_wtb = null;
                    if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["CSMSFTP_IP"]))
                        _ftp_wtb = new FtpWeb(ConfigurationManager.AppSettings["CSMSFTP_IP"], lujin, ConfigurationManager.AppSettings["CSMSFTP_ACCOUNT"], ConfigurationManager.AppSettings["CSMSFTP_PWD"]);
                    _ftp_wtb.Download(srcPath, FileNames);
                    LogUtil.Info("下载文件:" + ConfigurationManager.AppSettings["CSMSFTP_IP"] + "16022;" + ConfigurationManager.AppSettings["CSMSFTP_ACCOUNT"] + "|" + ConfigurationManager.AppSettings["CSMSFTP_PWD"] + _ftp_wtb.ftpURI + FileNames + "到本地。");                 
                    string requestUri = ConfigurationManager.AppSettings["RXGG_IP_DWJSC"] + "?SerialNumber=" + SerialNumber;//post请求  
                    LogUtil.Info("CSKHDSCWJN请求路径：" + requestUri);
                    wjcgsb = DKFUPLOADWJ(srcPath + @"\" + Filename, Filename, requestUri, out WJRESULT);//附件上传的返回值
                    LogUtil.Info("CSKHDSCWJN返回信息：" + WJRESULT);
                    if (wjcgsb)
                    {
                        V_Cfujian = WJRESULT;
                    }
                    else
                    {
                        _result = false;
                        return _result;
                    }


                    //}
                }
                return _result;
            }
            catch (Exception ex)
            {

                LogUtil.Info("CSKHDSCWJ:{0}", ex.Message);
                return false;
            }
        }
        #endregion
        #endregion
        #region 受益人
        public string WTB_SYRCCQuery(string canshu, string vcompany, string vusername, string vpassword)
        {
            string wybs = Guid.NewGuid().ToString();

            // 获取token
            ResultStringDataEntity tokenstring = GetToken(vcompany, vusername, vpassword);
            string token = tokenstring.result;

            ////调用第三方接口
            string url = ConfigurationManager.AppSettings["pljy"];
            LogUtil.Info("WTB_SYRCCQuery方法接收结果：" + url + "|" + canshu);
            HttpResult httpdata = PostHttpNewWeb(url, canshu, token);
            string JsonData = httpdata.html;
            LogUtil.Info("WTB_SYRCCQuery方法返回结果：" + JsonData);
            // string JsonData = "{\"requestId\":null,\"errCode\":null,\"errMessage\":null,\"success\":true,\"code\":\"200\",\"data\":{\"validList\":[],\"invalidList\":[\"333534543\",\"21313212\"]},\"msg\":null}";
            ResultOutDataEntity<WTB_SYRCCEntity> resultData = JsonConvert.DeserializeObject<ResultOutDataEntity<WTB_SYRCCEntity>>(JsonData);
            List<WTB_SYRCCEntity> res = new List<WTB_SYRCCEntity>();
            LogUtil.Info("WTB_SYRCCEntity方法接收返回参数：" + resultData.ToString());

            if (resultData.data.validList.Count == 0)
            {
                WTB_SYRCCEntity valist = new WTB_SYRCCEntity()
                {
                    SUCCESS = resultData.success.ToString() == null ? "" : resultData.success.ToString(),
                    CODE = resultData.code.ToString() == null ? "" : resultData.code.ToString(),
                    MSG = resultData.msg == null ? "" : resultData.msg,
                    WYBS = wybs
                };
                res.Add(valist);
            }
            else
            {
                for (int i = 0; i < resultData.data.validList.Count; i++)
                {
                    WTB_SYRCCEntity valist = new WTB_SYRCCEntity()
                    {
                        SUCCESS = resultData.success.ToString() == null ? "" : resultData.success.ToString(),
                        CODE = resultData.code.ToString() == null ? "" : resultData.code.ToString(),
                        MSG = resultData.msg == null ? "" : resultData.msg,
                        INCIDENTID = resultData.data.validList[i].INCIDENTID == null ? "" : resultData.data.validList[i].INCIDENTID,
                        SOURCE = resultData.data.validList[i].SOURCE == null ? "" : resultData.data.validList[i].SOURCE,
                        COMPANYNAME = resultData.data.validList[i].COMPANYNAME == null ? "" : resultData.data.validList[i].COMPANYNAME,
                        COMPANYCODE = resultData.data.validList[i].COMPANYCODE == null ? "" : resultData.data.validList[i].COMPANYCODE,
                        USERNO = resultData.data.validList[i].USERNO == null ? "" : resultData.data.validList[i].USERNO,
                        ADDRESS = resultData.data.validList[i].ADDRESS == null ? "" : resultData.data.validList[i].ADDRESS,
                        APPDATE = resultData.data.validList[i].APPDATE == null ? "" : resultData.data.validList[i].APPDATE,
                        STARTTIME = resultData.data.validList[i].STARTTIME == null ? "" : resultData.data.validList[i].STARTTIME,
                        ENDTIME = resultData.data.validList[i].ENDTIME == null ? "" : resultData.data.validList[i].ENDTIME,
                        BENEFICIARYNAME = resultData.data.validList[i].BENEFICIARYNAME == null ? "" : resultData.data.validList[i].BENEFICIARYNAME,
                        CARDNO = resultData.data.validList[i].CARDNO == null ? "" : resultData.data.validList[i].CARDNO,
                        APPIYSTATUS = resultData.data.validList[i].APPIYSTATUS == null ? "" : resultData.data.validList[i].APPIYSTATUS,
                        WYBS = wybs
                    };
                    res.Add(valist);
                }
            }

            List<string> res1 = new List<string>();
            string wybs1 = "";
            foreach (var item in resultData.data.invalidList)
            {
                wybs1 = new AccessDataBase().InsertNew_FSYRIN(item, wybs, null);
            }
            for (int i = 0; i < res.Count; i++)
            {
                wybs1 = new AccessDataBase().InsertWTB_SYRCC(res[i].SUCCESS, res[i].CODE, res[i].MSG, res[i].INCIDENTID, res[i].SOURCE, res[i].COMPANYNAME, res[i].COMPANYCODE, res[i].USERNO, res[i].ADDRESS, res[i].APPDATE, res[i].STARTTIME, res[i].ENDTIME, res[i].BENEFICIARYNAME, res[i].CARDNO, res[i].APPIYSTATUS, res[i].WYBS, null);
            }

            return wybs1;
        }

        public ResultStringDataEntity GetToken(string vcompany, string vusername, string vpassword)
        {
            try
            {
                string token = _BusinessLogsticBase.GetToken(vcompany, vusername, vpassword);
                if (!string.IsNullOrWhiteSpace(token))
                {
                    ResultStringDataEntity result = new ResultStringDataEntity()
                    {
                        isSuccess = true,
                        code = 200,
                        message = "",
                        result = token
                    };
                    return result;
                }
                else
                {
                    ResultStringDataEntity result = new ResultStringDataEntity()
                    {
                        isSuccess = false,
                        code = 500,
                        message = "token未获取到",
                        result = null
                    };
                    return result;
                }
            }
            catch (Exception ex)
            {
                ResultStringDataEntity result = new ResultStringDataEntity()
                {
                    isSuccess = false,
                    code = 500,
                    message = ex.Message,
                    result = null
                };
                return result;
            }
        }

        public HttpResult PostHttpNewWeb(string url, string paramStr, string token)
        {
            HttpResult result = _BusinessLogsticBase.PostHttpNewWeb(url, paramStr, token);
            return result;
        }

        public int BeneficiaryInsert(string PortType, string requestId, string errCode, string errMessage, Boolean RequestState, int StatusCode, string data, string Message, string InsertDatetime, string incidentId)
        {
            int result = _AccessDataBase.BeneficiaryInsert_AddProc(PortType, requestId, errCode, errMessage, RequestState, StatusCode, data, Message, InsertDatetime, incidentId, null);
            return result;
        }
        public int BeneficiaryQuery_MessageProc(string pid, string BanjianNumber, string Soure, string CompanyName, string CompanyCode, string HouseNumber, string UseWaterLocation, string ApplyDate, string Startdate, string Enddate, string BeneficiaryName, string BeneficiarySFZNumber, string ApplyStatus)
        {
            int result = _AccessDataBase.BeneficiaryQuery_MessageProc(pid, BanjianNumber, Soure, CompanyName, CompanyCode, HouseNumber, UseWaterLocation, ApplyDate, Startdate, Enddate, BeneficiaryName, BeneficiarySFZNumber, ApplyStatus, null);
            return result;
        }
        public int BeneficiaryQuery(string requestid, string errcode, string errmessage, Boolean RequestState, int StatusCode, string Message, string pid)
        {
            int result = _AccessDataBase.BeneficiaryQuery_QueryProc(requestid, errcode, errmessage, RequestState, StatusCode, Message, pid, null);
            return result;
        }
        public string BeneficiaryInsertNew(string jaoncanshu, string vcompany, string vusername, string vpassword)
        {
            LogUtil.Info("BeneficiaryInsertNew方法接收结果：" + jaoncanshu);
            string ss = "0";
            string sa = ss.Substring(0, 1);
            string sd = ss.Substring(1);
            string sj = DateTime.Now.ToShortDateString();
            string time = DateTime.Now.ToShortTimeString();
            string zd = DateTime.Now.ToString();
            #region 第三方接口数据
            addBeneficiaryInput model = JsonConvert.DeserializeObject<addBeneficiaryInput>(jaoncanshu);
            //string jaoncanshu = JsonConvert.SerializeObject(canshu);
            string url = ConfigurationManager.AppSettings["BeneficiaryInsert"];
            //获取token
            ResultStringDataEntity token = GetToken(vcompany, vusername, vpassword);
            HttpResult resultJson = PostHttpNewWeb(url, jaoncanshu, token.result);
            string JsonData = resultJson.html;
            LogUtil.Info("BeneficiaryInsertNew方法返回结果：" + JsonData);
            ResultOutEntity resultData = JsonConvert.DeserializeObject<ResultOutEntity>(JsonData);
            //接口标识
            string PortType = "BeneficiaryInsert";
            string requestId = resultData.requestId == null ? "" : resultData.requestId;
            string errCode = resultData.errCode == null ? "" : resultData.errCode;
            string errMessage = resultData.errMessage == null ? "" : resultData.errMessage;
            //success 成功:true;失败:false;
            Boolean RequestState = resultData.success;
            //状态码
            int StatusCode = resultData.code;
            string data = resultData.data == null ? "" : resultData.data;
            //消息
            string Message = resultData.msg == null ? "" : resultData.msg;
            string InsertDatetime = DateTime.Now.ToString();
            #endregion
            int result = BeneficiaryInsert(PortType, requestId, errCode, errMessage, RequestState, StatusCode, data, Message, InsertDatetime, model.incidentId);
            if (RequestState)
            {
                return "1" + resultData.msg;
            }
            else
            {
                return "0" + resultData.msg;
            }
        }
        public string BeneficiaryUpdateNEW(string incidentId, string companyCode, string userNo, string endTime, int applyStatus, string vcompany, string vusername, string vpassword)
        {
            updateBeneficiaryInput canshu = new updateBeneficiaryInput()
            {
                incidentId = incidentId,
                companyCode = companyCode,
                userNo = userNo,
                endTime = endTime,
                applyStatus = 0
            };
            string jsonCanshu = JsonConvert.SerializeObject(canshu);
            LogUtil.Info("BeneficiaryUpdateNEW方法接收结果：" + jsonCanshu);
            string url = ConfigurationManager.AppSettings["BeneficiaryUpdate"];
            //获取token
            ResultStringDataEntity token = GetToken(vcompany, vusername, vpassword);
            HttpResult jsonresult = PostHttpNewWeb(url, jsonCanshu, token.result);
            string JsonData = jsonresult.html;
            ResultOutEntity resultData = JsonConvert.DeserializeObject<ResultOutEntity>(JsonData);
            LogUtil.Info("BeneficiaryUpdateNEW方法返回结果：" + JsonData);
            //接口标识
            string PortType = "BeneficiaryUpdate";
            string requestId = resultData.requestId == null ? "" : resultData.requestId;
            string errCode = resultData.errCode == null ? "" : resultData.errCode;
            string errMessage = resultData.errMessage == null ? "" : resultData.errMessage;
            //success 成功:true;失败:false;
            Boolean RequestState = resultData.success;
            //状态码
            int StatusCode = resultData.code;
            string data = resultData.data == null ? "" : resultData.data;
            //消息
            string Message = resultData.msg == null ? "" : resultData.msg;
            string InsertDatetime = DateTime.Now.ToString();
            int result = BeneficiaryInsert(PortType, requestId, errCode, errMessage, RequestState, StatusCode, data, Message, InsertDatetime, incidentId);
            if (RequestState)
            {
                return "1" + resultData.msg;
            }
            else
            {
                return "0" + resultData.msg;
            }
        }
        public string WTB_BJSLHDQuery(string startTime, string endTime, string companyCode, string incidentId, string userNo, string vcompany, string vusername, string vpassword)
        {
            try
            {
                string wybs = Guid.NewGuid().ToString();
                List<incidentList> list = new List<incidentList>();
                DataSet ds = new AccessDataBase().GETHDBJ(startTime, endTime, null);
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow item in ds.Tables[0].Rows)
                    {
                        incidentList list1 = new incidentList();
                        list1.incidentId = item["incidentId"].ToString();
                        list1.userNo = item["userNo"].ToString();
                        list.Add(list1);
                    }
                }
                BJJLQQCS bjjl = new BJJLQQCS()
                {
                    startTime = startTime,
                    endTime = endTime,
                    companyCode = companyCode,
                    incidentList = list
                };
                string jkcs = JsonConvert.SerializeObject(bjjl);

                LogUtil.Info("WTB_BJSLHDQuery方法接收请求：" + jkcs);
                // 获取token
                ResultStringDataEntity tokenstring = GetToken(vcompany, vusername, vpassword);
                string token = tokenstring.result;

                //调用第三方接口
                string url = ConfigurationManager.AppSettings["bjjl"];

                HttpResult httpdata = PostHttpNewWeb(url, jkcs, token);
                string JsonData = httpdata.html;

                LogUtil.Info("WTB_BJSLHDQuery方法返回请求：" + JsonData);
                // string JsonData = "{\"requestId\":null,\"errCode\":null,\"errMessage\":null,\"success\":true,\"code\":\"200\",\"msg\":213213,\"data\":{\"middleIncidentList\":[{\"SUCCESS\":\"成功\",\"CODE\":\"200\",\"MSG\":\"123\",\"INCIDENTID\":\"123\",\"USERNO\":\"123\"},{\"SUCCESS\":\"成功\",\"CODE\":\"200\",\"MSG\":\"123\",\"INCIDENTID\":\"123\",\"USERNO\":\"123\"}] ,\"businessIncidentList\":[{\"SUCCESS\":\"成功\",\"CODE\":\"200\",\"MSG\":\"123\",\"INCIDENTIDS\":\"123\",\"USERNOS\":\"123\"},{\"SUCCESS\":\"成功\",\"CODE\":\"200\",\"MSG\":\"123\",\"INCIDENTIDS\":\"123\",\"USERNOS\":\"123\"}]},\"msg\":null}";
                ResultOutDataEntity<WTB_BJSLHDEntity> resultData = JsonConvert.DeserializeObject<ResultOutDataEntity<WTB_BJSLHDEntity>>(JsonData);
                List<YWXTBJ> res = new List<YWXTBJ>();
                if (resultData.data.middleIncidentList.Count > 0)
                {
                    for (int i = 0; i < resultData.data.middleIncidentList.Count; i++)
                    {
                        YWXTBJ jh = new YWXTBJ()
                        {
                            SUCCESS = resultData.code.ToString() == null ? "" : resultData.code.ToString(),
                            CODE = resultData.code.ToString() == null ? "" : resultData.code.ToString(),
                            INCIDENTIDS = resultData.data.middleIncidentList[0].INCIDENTID == null ? "" : resultData.data.middleIncidentList[0].INCIDENTID,
                            USERNOS = resultData.data.middleIncidentList[0].USERNO == null ? "" : resultData.data.middleIncidentList[0].USERNO,
                            wybs = DateTime.Now.ToShortDateString() + "中间库多"
                        };
                        if (string.IsNullOrWhiteSpace(resultData.msg))
                        {
                            jh.MSG = "";
                        }
                        else
                        {
                            jh.MSG = resultData.msg;
                        }
                        res.Add(jh);
                    }
                }
                List<YWXTBJ> res1 = new List<YWXTBJ>();


                if (resultData.data.businessIncidentList.Count > 0)
                {
                    for (int i = 0; i < resultData.data.businessIncidentList.Count; i++)
                    {

                        YWXTBJ jh1 = new YWXTBJ()
                        {
                            SUCCESS = resultData.success.ToString() == null ? "" : resultData.success.ToString(),
                            CODE = resultData.code.ToString() == null ? "" : resultData.code.ToString(),
                            INCIDENTIDS = resultData.data.businessIncidentList[i].INCIDENTID == null ? "" : resultData.data.businessIncidentList[i].INCIDENTID,
                            USERNOS = resultData.data.businessIncidentList[i].USERNO == null ? "" : resultData.data.businessIncidentList[i].USERNO,
                            wybs = DateTime.Now.ToShortDateString() + "业务系统多"
                        };
                        ADDSYR(ds, jh1.USERNOS, jh1.INCIDENTIDS, startTime, vcompany, vusername, vpassword);
                        if (string.IsNullOrWhiteSpace(resultData.msg))
                        {
                            jh1.MSG = "";
                        }
                        else
                        {
                            jh1.MSG = resultData.msg;
                        }
                        res1.Add(jh1);
                    }
                }

                string wybs1 = "";
                if (res1.Count > 0)
                {
                    for (int i = 0; i < res.Count; i++)
                    {
                        wybs1 = new AccessDataBase().InsertWTB_BJSLHD(res[i].SUCCESS, res[i].CODE, res[i].MSG, res[i].INCIDENTIDS, res[i].USERNOS, wybs, null);
                    }
                }
                if (res1.Count > 0)
                {
                    for (int i = 0; i < res1.Count; i++)
                    {
                        wybs1 = new AccessDataBase().InsertWTB_BJSLHD(res1[i].SUCCESS, res1[i].CODE, res1[i].MSG, res1[i].INCIDENTIDS, res1[i].USERNOS, wybs, null);
                    }
                }
                if (res1.Count == 0 && res1.Count == 0)
                {
                    wybs1 = new AccessDataBase().InsertWTB_BJSLHD(resultData.success.ToString() == null ? "" : resultData.success.ToString(), resultData.code.ToString() == null ? "" : resultData.code.ToString(), resultData.msg, null, null, DateTime.Now.ToShortDateString() + "核对成功", null);
                }
                return wybs1;
            }
            catch (Exception EX)
            {
                LogUtil.Info("WTB_BJSLHDQuery方法错误结果：" + EX.Message);
                return "0";
            }
            //return resultData.success + resultData.msg + resultData.data.middleIncidentList[0].INCIDENTID;
        }
        public string ADDSYR(DataSet ds, string s_Cid, string INCIDENTIDS, string startTime, string vcompany, string vusername, string vpassword)
        {
            string proofResidenceType = "";
            string proofResidenceNo = "";
            string applicant = "";
            string applicantCertNo = "";
            string identificationPapersType = "";
            string identificationPapersValidDate = "";
            string KSRQ = "";
            string JSRQ = "";
            beneficiaryList result1 = null;
            List<beneficiaryList> beneficiaryresult = new List<beneficiaryList>();
            List<BatchBeneficiarys> batchBeneficiarys = new List<BatchBeneficiarys>();
            BatchBeneficiarys result2 = null;
            DataSet SYR = _AccessDataBase.GetParamsDataSource("<Procedure>", "INSERT; KHGX_SelKG_YHDRKYONGHUGC; " + "S_BEIYONG4='" + INCIDENTIDS + "'" + " ;null;null", "");
            //GETSYRBYKID 市北
            DataSet xy = _AccessDataBase.GetParamsDataSource("<Procedure>", "SELECT;New_IFXY;" + s_Cid + ";", "");

            DataRow[] DR = ds.Tables[0].Select("incidentId = '" + INCIDENTIDS + "'");
            string handleWay;
            if (xy != null && xy.Tables.Count > 0 && xy.Tables[0].Rows.Count > 0 && DR[0]["S_BEIZHU10"].ToString() == "1")
            {
                KSRQ = xy.Tables[0].Rows[0]["D_JIETI_KSRQ"].ToString();
                DateTime end = Convert.ToDateTime(xy.Tables[0].Rows[0]["D_JIETI_JZRQ"].ToString()).AddMonths(24);
                JSRQ = xy.Tables[0].Rows[0]["D_JIETI_JZRQ"].ToString();
                handleWay = "2";
            }
            else
            {
                KSRQ = Convert.ToDateTime(startTime).AddDays(1 - Convert.ToDateTime(startTime).Day).AddMonths(1).AddHours(-Convert.ToDateTime(startTime).Hour + 1).AddMinutes(-Convert.ToDateTime(startTime).Minute).AddSeconds(-Convert.ToDateTime(startTime).Second).ToString();
                DateTime end = Convert.ToDateTime(KSRQ).AddMonths(24);
                JSRQ = end.AddDays(1 - end.Day).AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
                handleWay = "1";
            }
            if (SYR != null && SYR.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow item in SYR.Tables[0].Rows)
                {
                    string lx = item.ItemArray[2].ToString();
                    if (lx.Contains("申请人"))
                    {
                        proofResidenceType = item["S_FCZJLX"].ToString();
                        proofResidenceNo = item["S_FCZJID"].ToString();
                        applicant = item["S_YONGHUMING"].ToString();
                        applicantCertNo = item["S_ZHANGJIANH"].ToString();
                        identificationPapersType = item["ZHENGJIANLX"].ToString();
                        identificationPapersValidDate = null;
                    }
                    if (lx.Contains("受益人"))
                    {
                        result1 = new beneficiaryList()
                        {
                            beneficiaryName = item["S_YONGHUMING"].ToString(),
                            cardNo = item["S_ZHANGJIANH"].ToString(),
                            identificationPapersType = item["ZHENGJIANLX"].ToString(),
                            proofResidenceValidDate = null,
                            proofResidenceType = item["S_JZZJLX"].ToString(),
                        };
                        result2 = new BatchBeneficiarys()
                        {
                            cardNo = item.ItemArray[4].ToString(),
                            name = item.ItemArray[5].ToString(),
                            certType = item["ZHENGJIANLX"].ToString()
                        };
                        batchBeneficiarys.Add(result2);
                        beneficiaryresult.Add(result1);
                    }
                }
            }
            string source;
            if (SYR.Tables[0].Rows[0]["S_CAOZUOR"].ToString() == "一网通办")
                source = "1";
            else
                source = "50";
            addBeneficiaryInput input = new addBeneficiaryInput()
            {

                incidentId = INCIDENTIDS,
                applicant = applicant,
                address = DR[0]["S_DZ"].ToString(),
                applicantCertNo = applicantCertNo.ToString(),
                identificationPapersType = identificationPapersType.ToString(),
                identificationPapersValidDate = identificationPapersValidDate,
                proofResidenceType = proofResidenceType,
                proofResidenceNo = proofResidenceNo,
                companyCode = "PDXQZLS",
                companyName = "PDXQZLS",
                userNo = s_Cid,
                startTime = Convert.ToDateTime(KSRQ).ToString("yyyy-MM-dd HH:mm:ss"),
                endTime = JSRQ,
                applyStatus = "1",
                appdate = Convert.ToDateTime(DR[0]["D_KAISHISJ"].ToString()).ToString("yyyy-MM-dd HH:mm:ss"),
                approvalTime = startTime,
                source = source,
                beneficiaryList = beneficiaryresult
            };
            string cashu = JsonConvert.SerializeObject(input);
            //批量查重
            BatchBeneficiary input1 = new BatchBeneficiary()
            {
                userNo = s_Cid,
                cardNoList = batchBeneficiarys,
                handleWay = handleWay
            };
            string canshuCC = JsonConvert.SerializeObject(input1);
            string CCRESULT = WTB_SYRCCQuery(canshuCC, vcompany, vusername, vpassword);
            DataTable set = _AccessDataBase.GetParamsDataSource("<Procedure>", "SELECT;New_SYRJYCHS;" + CCRESULT + ";", "").Tables[0];
            if (set.Rows[0]["SUCCESS"].ToString() == "True" && set.Rows[0]["BENEFICIARYNAME"].ToString() != "")
            {
                LogUtil.Info("New_SYRJYCHS方法受益人重复：" + INCIDENTIDS);
                return null;
            }
            LogUtil.Info("BeneficiaryUpdateNEW方法更新受益人失效：" + INCIDENTIDS);
            BeneficiaryUpdateNEW(INCIDENTIDS, "PDXQZLS", s_Cid, startTime, 0, vcompany, vusername, vpassword);
            LogUtil.Info("WTB_BJSLHDQuery方法新增受益人：" + INCIDENTIDS);
            BeneficiaryInsertNew(cashu, vcompany, vusername, vpassword);
            return null;
        }
        #endregion

    }

    public class PostInfo
    {
        public string url { get; set; }

        public string body { get; set; }
    }

}